/** * Event that is called at the end of processing the document. */ public void endDocument() throws SAXException { endDocumentTriggered = true; super.endDocument(); }
/** * Event that is called at the start of processing the document. */ public void startDocument() throws SAXException { endDocumentTriggered = false; super.startDocument(); }
public Document parse(Source source) throws XMLPlatformException { try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); SAXResult saxResult = new SAXResult(); SAXDocumentBuilder builder = new SAXDocumentBuilder(); saxResult.setHandler(builder); transformer.transform(source, saxResult); return builder.getDocument(); } catch (TransformerException e) { throw XMLPlatformException.xmlPlatformParseException(e); } }
this.documentBuilder = new SAXDocumentBuilder(); documentBuilder.startDocument(); documentBuilder.startPrefixMapping(prefix, this.unmarshalNamespaceResolver.getNamespaceURI(prefix)); documentBuilder.startElement(namespaceURI, localName, qName, atts); this.xmlReader.setContentHandler(documentBuilder); return;
namespaceURI = null; Element element = getInitializedDocument().createElementNS(namespaceURI, qName); Node parentNode = (Node)nodes.get(nodes.size()-1); Text text = getInitializedDocument().createTextNode(stringBuffer.toString()); parentNode.appendChild(text); stringBuffer.reset(); appendChildNode(parentNode, element); nodes.add(element); prefix = (String)namespacePrefixes.next(); uri = (String)namespaceDeclarations.get(prefix); addNamespaceDeclaration(element, prefix, uri);
public void processingInstruction(String target, String data) throws SAXException { ProcessingInstruction pi = getInitializedDocument().createProcessingInstruction(target, data); Node parentNode = nodes.get(nodes.size() -1); parentNode.appendChild(pi); }
public void endSelfElement(String namespaceURI, String localName, String qName) throws SAXException { if (super.nodes.size() == 2) { Element endedElement = (Element)nodes.get(nodes.size() -1); if (stringBuffer.length() > 0) { Text text = getInitializedDocument().createTextNode(stringBuffer.toString()); endedElement.appendChild(text); stringBuffer.reset(); } } else { super.endElement(namespaceURI, localName, qName); } } public List<Node> getNodes() {
public Object getObject() { if(object == null) { if(this.descriptor != null) { object = this.descriptor.wrapObjectInXMLRoot(this.rootRecord, this.unmarshaller.isResultAlwaysXMLRoot()); } else if(documentBuilder != null) { Node node = (Node)documentBuilder.getDocument().getDocumentElement(); XMLRoot root = new XMLRoot(); root.setLocalName(node.getLocalName()); root.setNamespaceURI(node.getNamespaceURI()); root.setObject(node); object = root; } else { if(rootRecord != null) { object = this.rootRecord.getCurrentObject(); } } } return this.object; }
this.documentBuilder = new SAXDocumentBuilder(); documentBuilder.startDocument(); documentBuilder.startPrefixMapping(prefix, this.unmarshalNamespaceResolver.getNamespaceURI(prefix)); documentBuilder.startElement(namespaceURI, localName, qName, atts); this.xmlReader.setContentHandler(documentBuilder); return;
namespaceURI = null; Element element = getInitializedDocument().createElementNS(namespaceURI, qName); Node parentNode = nodes.get(nodes.size()-1); Text text = getInitializedDocument().createTextNode(stringBuffer.toString()); parentNode.appendChild(text); stringBuffer.reset(); appendChildNode(parentNode, element); nodes.add(element); addNamespaceDeclaration(element, prefix, uri);
public void processingInstruction(String target, String data) throws SAXException { ProcessingInstruction pi = getInitializedDocument().createProcessingInstruction(target, data); Node parentNode = nodes.get(nodes.size() -1); parentNode.appendChild(pi); }
public void endSelfElement(String namespaceURI, String localName, String qName) throws SAXException { if (super.nodes.size() == 2) { Element endedElement = (Element)nodes.get(nodes.size() -1); if (stringBuffer.length() > 0) { Text text = getInitializedDocument().createTextNode(stringBuffer.toString()); endedElement.appendChild(text); stringBuffer.reset(); } } else { super.endElement(namespaceURI, localName, qName); } } public List<Node> getNodes() {
public Object getObject() { if(object == null) { if(this.descriptor != null) { if(this.unmarshaller.isResultAlwaysXMLRoot() || descriptor.isResultAlwaysXMLRoot() || shouldWrap){ object = this.descriptor.wrapObjectInXMLRoot(this.rootRecord, (this.unmarshaller.isResultAlwaysXMLRoot() || descriptor.isResultAlwaysXMLRoot())); }else { object = this.rootRecord.getCurrentObject(); } } else if(documentBuilder != null) { Node node = documentBuilder.getDocument().getDocumentElement(); Root root = unmarshaller.createRoot(); root.setLocalName(node.getLocalName()); root.setNamespaceURI(node.getNamespaceURI()); root.setObject(node); object = root; } else { if(rootRecord != null) { object = this.rootRecord.getCurrentObject(); } } } return this.object; }
this.documentBuilder = new SAXDocumentBuilder(); documentBuilder.startDocument(); documentBuilder.startPrefixMapping(prefix, this.unmarshalNamespaceResolver.getNamespaceURI(prefix)); documentBuilder.startElement(namespaceURI, localName, qName, atts); this.xmlReader.setContentHandler(documentBuilder); return;
/** * Parses given source. * * @param source source to parse * @return parsed document * @throws XMLPlatformException exception occurred while parsing given source */ public Document parse(Source source) throws XMLPlatformException { try { if (null == transformerFactory) { transformerFactory = TransformerFactory.newInstance(); } Transformer transformer = transformerFactory.newTransformer(); SAXResult saxResult = new SAXResult(); SAXDocumentBuilder builder = new SAXDocumentBuilder(); saxResult.setHandler(builder); transformer.transform(source, saxResult); return builder.getDocument(); } catch (TransformerException e) { throw XMLPlatformException.xmlPlatformParseException(e); } }
namespaceURI = null; Element element = getInitializedDocument().createElementNS(namespaceURI, qName); Node parentNode = nodes.get(nodes.size()-1); Text text = getInitializedDocument().createTextNode(stringBuffer.toString()); parentNode.appendChild(text); stringBuffer.reset(); appendChildNode(parentNode, element); nodes.add(element); addNamespaceDeclaration(element, prefix, uri);
/** * Event that is called at the start of processing the document. */ public void startDocument() throws SAXException { endDocumentTriggered = false; super.startDocument(); }
/** * Event that is called at the end of processing the document. */ public void endDocument() throws SAXException { endDocumentTriggered = true; super.endDocument(); }
public void processingInstruction(String target, String data) throws SAXException { ProcessingInstruction pi = getInitializedDocument().createProcessingInstruction(target, data); Node parentNode = nodes.get(nodes.size() -1); parentNode.appendChild(pi); }
public void endSelfElement(String namespaceURI, String localName, String qName) throws SAXException { if (super.nodes.size() == 2) { Element endedElement = (Element)nodes.get(nodes.size() -1); if (stringBuffer.length() > 0) { Text text = getInitializedDocument().createTextNode(stringBuffer.toString()); endedElement.appendChild(text); stringBuffer.reset(); } } else { super.endElement(namespaceURI, localName, qName); } } public List<Node> getNodes() {