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 MapXml createMapXml(ServiceContext context) { xsltEvaluator.setUriResolverFactory(context.getUriResolverFactory()); // System.out.println("MultipleMapXmlFactory.createMapXml"); MapXml rm = null; if (headerCount == recordMappingFactories.length) { MapXml[] children = new MapXml[recordMappingFactories.length]; for (int i = 0; i < recordMappingFactories.length; ++i) { MapXmlFactory childFactory = recordMappingFactories[i]; // System.out.println(getClass().getName()+".createMapXml (simple) " + // childFactory.getClass().getName()); children[i] = childFactory.createMapXml(context); } // System.out.println(getClass().getName()+".createMapXml SimpleRecordMapContainer"); rm = new SimpleRecordMapContainer(children, xsltEvaluator); } else { MapXml[] children1 = new MapXml[headerCount]; MapXml[] children2 = new MapXml[bodyCount]; MapXml[] children3 = new MapXml[trailerCount]; int index1 = 0; int index2 = 0; int index3 = 0; for (int i = 0; i < recordMappingFactories.length; ++i) { MapXmlFactory childFactory = recordMappingFactories[i]; if (i >= startRecordOrGroup && i < endRecordOrGroup) { children2[index2++] = childFactory.createMapXml(context); // System.out.println(getClass().getName()+".createMapXml 2 " + // childFactory.getClass().getName()); } else if (i < startRecordOrGroup) { children1[index1++] = childFactory.createMapXml(context); // System.out.println(getClass().getName()+".createMapXml 1 " + // childFactory.getClass().getName()); } else { children3[index3++] = childFactory.createMapXml(context); // System.out.println(getClass().getName()+".createMapXml 3 " + // childFactory.getClass().getName()); } } if (bodyCount == 1 || bodyCount == onRecordCount) { rm = new SimpleGroupingRecordMapContainer(children1, children2, children3, xsltEvaluator); } rm = new MultipleGroupingRecordMapContainer(children1, children2, children3, xsltEvaluator); // System.out.println("MultipleMapXmlFactory.createMapXml // MultipleGroupingRecordMapContainer"); } return rm; }