public void endElement(String namespaceUri, String localName, String qname) throws SAXException { --level; // System.out.println(getClass().getName()+".endElement enter " + qname); try { StackContext stackEntry = stack.peek(); SaxEventBufferBuilder bufferBuilder = stackEntry.bufferBuilder; if (bufferBuilder != null) { bufferBuilder.endElement(namespaceUri, localName, qname); if (level == 0) { bufferBuilder.endDocument(); SaxEventBuffer buffer = bufferBuilder.getBuffer(); SaxSource saxSource = new SaxEventBufferSource(buffer, "", context.getTransformerFactory()); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); builderFactory.setValidating(false); builderFactory.setNamespaceAware(true); DocumentBuilder builder = builderFactory.newDocumentBuilder(); XMLReader reader = saxSource.createXmlReader(); // InputSource inputSource = new InputSource(reader); // Document doc = builder.parse(inputSource); } } stack.pop(); } catch (ServingXmlException e) { throw new SAXException(e.getMessage(), e); } catch (Exception e) { throw new SAXException(e.getMessage(), e); } super.endElement(namespaceUri, localName, qname); // System.out.println(getClass().getName()+".endElement " + qname + " leave"); }
public void startElement(String namespaceUri, String localName, String qname, Attributes atts) throws SAXException { // System.out.println(getClass().getName()+".startElement ns=" + namespaceUri + ", name=" + // localName + ", qname=" + qname); StackContext stackEntry = stack.peek(); SaxPath saxPathParent = stackEntry.saxPath; SaxPath saxPath; if (saxPathParent == null) { saxPath = new SaxPath(context.getNameTable(), namespaceUri, localName, qname, atts); } else { saxPath = new SaxPath(namespaceUri, localName, qname, atts, saxPathParent); } SaxEventBufferBuilder bufferBuilder = stackEntry.bufferBuilder; // System.out.println(getClass().getName()+".startElement matched"); // if (saxPathParent == null) { if (level == 0) { bufferBuilder = new SaxEventBufferBuilder(); bufferBuilder.startDocument(); Iterator<Map.Entry<String, String>> iter = prefixMap.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, String> entry = iter.next(); bufferBuilder.startPrefixMapping(entry.getValue(), entry.getKey()); } } if (bufferBuilder != null) { bufferBuilder.startElement(namespaceUri, localName, qname, atts); } stack.push(new StackContext(saxPath, bufferBuilder)); super.startElement(namespaceUri, localName, qname, atts); ++level; // System.out.println(getClass().getName()+".startElement " + qname + " leave"); }
public void characters(char[] ch, int start, int length) throws SAXException { StackContext stackEntry = stack.peek(); SaxEventBufferBuilder bufferBuilder = stackEntry.bufferBuilder; if (bufferBuilder != null) { bufferBuilder.characters(ch, start, length); } super.characters(ch, start, length); }
public void skippedEntity(String name) throws SAXException { StackContext stackEntry = stack.peek(); SaxEventBufferBuilder bufferBuilder = stackEntry.bufferBuilder; if (bufferBuilder != null) { bufferBuilder.skippedEntity(name); } super.skippedEntity(name); }
public void processingInstruction(String target, String data) throws SAXException { StackContext stackEntry = stack.peek(); SaxEventBufferBuilder bufferBuilder = stackEntry.bufferBuilder; if (bufferBuilder != null) { bufferBuilder.processingInstruction(target, data); } super.processingInstruction(target, data); }
public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { StackContext stackEntry = stack.peek(); SaxEventBufferBuilder bufferBuilder = stackEntry.bufferBuilder; if (bufferBuilder != null) { bufferBuilder.ignorableWhitespace(ch, start, length); } super.ignorableWhitespace(ch, start, length); }
public void endPrefixMapping(String prefix) throws SAXException { StackContext stackEntry = stack.peek(); SaxEventBufferBuilder bufferBuilder = stackEntry.bufferBuilder; if (bufferBuilder != null) { bufferBuilder.endPrefixMapping(prefix); } super.endPrefixMapping(prefix); }
public void setDocumentLocator(Locator locator) { if (stack != null && !stack.empty()) { StackContext stackEntry = stack.peek(); SaxEventBufferBuilder bufferBuilder = stackEntry.bufferBuilder; if (bufferBuilder != null) { bufferBuilder.setDocumentLocator(locator); } } super.setDocumentLocator(locator); }
public void startPrefixMapping(String prefix, String uri) throws SAXException { // System.out.println(getClass()+".startPrefixMapping " + prefix+":" + uri); StackContext stackEntry = stack.peek(); SaxEventBufferBuilder bufferBuilder = stackEntry.bufferBuilder; if (bufferBuilder != null) { bufferBuilder.startPrefixMapping(prefix, uri); } else { prefixMap.put(uri, prefix); } super.startPrefixMapping(prefix, uri); }