1 16 package org.apache.cocoon.components.xpointer; 17 18 import org.apache.cocoon.xml.dom.DOMStreamer; 19 import org.apache.cocoon.ResourceNotFoundException; 20 import org.w3c.dom.Document ; 21 import org.w3c.dom.Element ; 22 import org.xml.sax.SAXException ; 23 24 31 public class ShorthandPart implements PointerPart { 32 private String shorthand; 33 34 public ShorthandPart(String shorthand) { 35 this.shorthand = shorthand; 36 } 37 38 public boolean process(XPointerContext xpointerContext) throws SAXException , ResourceNotFoundException { 39 Document document = xpointerContext.getDocument(); 40 Element element = document.getElementById(shorthand); 41 if (element != null) { 42 DOMStreamer streamer = new DOMStreamer(); 43 streamer.setConsumer(xpointerContext.getXmlConsumer()); 44 streamer.stream(element); 45 return true; 46 } else { 47 if (xpointerContext.getLogger().isDebugEnabled()) 48 xpointerContext.getLogger().debug("XPointer: found no element with id " + shorthand + " in document " + xpointerContext.getSource().getURI()); 49 } 50 return false; 51 } 52 } 53 | Popular Tags |