StringBuilder styles = new StringBuilder(); boolean writeStyles = false; public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { if (localName.equalsIgnoreCase("link")) { // If the element currently in queue is a link tag inspect it String href = atts.getValue("href"); String rel = atts.getValue("rel"); if (rel.equalsIgnoreCase("stylesheet")) { String css = ""; // TODO: Load the stylesheet from the JCR, store it with others loaded // so far and append to styles } return; } if (localName.equalsIgnoreCase("style")) { if (atts.getIndex("amp-custom")) { writeStyles = true; // TODO: Use this flag to emit all styles gathered in styles // in the transformer's characters method } return; } contentHandler.startElement(uri, localName, qName, atts); }
<ampJS jcr:primaryType="bmw:ampJSResource" bmw:ampCustomElementTag="[amp-video]"/>
final PageManager pageManager = resource.getResourceResolver().adaptTo(PageManager.class); final String currentPage = pageManager.getContainingPage(resource).getPath() + "/jcr:content"; final String query = String.format("SELECT * FROM [bmw:ampResourceHint] AS s WHERE ISDESCENDANTNODE(s,'%s')", currentPage); final Iterator<Resource> result = resource.getResourceResolver().findResources(query, Query.JCR_SQL2); while (result.hasNext()) { Resource queryResource = result.next(); final String type = queryResource.getParent().getResourceType(); ValueMap properties = queryResource.adaptTo(ValueMap.class); String[] usedComponents = properties.get("bmw:usedAmpComponents", String[].class); if (usedComponents != null && usedComponents.length != 0) { // TODO: Store all used components somewhere for later rendering } }