/** * Create a new row/record for the object builder with the given name. * This allows subclasses to define different record types. */ public AbstractMarshalRecord createRecord(String rootName, AbstractSession session) { NodeRecord nRec = new NodeRecord(rootName, getNamespaceResolver()); nRec.setSession(session); return nRec; }
/** * INTERNAL: * Create a record with the root element name get the namespace URI from the namespaceResolver. */ public NodeRecord(String rootElementName, NamespaceResolver namespaceResolver) { this(); String rootElementNamespaceURI = resolveNamespace(namespaceResolver, rootElementName); Node rootElement = document.createElementNS(rootElementNamespaceURI, rootElementName); document.appendChild(rootElement); setDOM(rootElement); }
/** * INTERNAL: */ public void attribute(XPathFragment xPathFragment, NamespaceResolver namespaceResolver, String value) { if (node.getNodeType() == Node.ELEMENT_NODE) { ((Element)getDOM()).setAttributeNS(xPathFragment.getNamespaceURI(), getNameForFragment(xPathFragment), value); } }
/** * INTERNAL: * Create a record with the element. */ public NodeRecord(Node node) { setDOM(node); getNamespaceResolver().setDOM(node); }
marshalRecord.flush(); } else if(result instanceof DOMResult) { NodeRecord marshalRecord = new NodeRecord(); marshalRecord.setDOM(((DOMResult)result).getNode()); marshalRecord.setMarshaller(anXMLMarshaller); listener.setRootMarshalRecord(marshalRecord); anXMLMarshaller.marshal(xmlDocument, marshalRecord); marshalRecord.flush(); } else { StringWriter writer = new StringWriter();
NodeRecord contentHandlerRecord = new NodeRecord(node); contentHandlerRecord.setMarshaller(this); if (!isXMLRoot) { if ((null == xmlDescriptor.getDefaultRootElement()) && (node.getNodeType() == Node.ELEMENT_NODE) && (xmlDescriptor.getSchemaReference() != null) && (xmlDescriptor.getSchemaReference().getType() == XMLSchemaReference.COMPLEX_TYPE)) {
/** * INTERNAL: * Convert the given object to an XML Document * @param object the object to marshal * @return the document which the specified object has been marshalled to * @param descriptor the XMLDescriptor for the object being marshalled * @throws XMLMarshalException if an error occurred during marshalling */ protected Document objectToXML(Object object, DESCRIPTOR descriptor, boolean isXMLRoot) throws XMLMarshalException { ABSTRACT_SESSION session = context.getSession(descriptor); MarshalRecord marshalRecord = new NodeRecord(); marshalRecord.setMarshaller(this); marshal(object, marshalRecord, session, descriptor, isXMLRoot); return marshalRecord.getDocument(); }
attribute(attr.getNamespaceURI(), XMLConstants.EMPTY_STRING, resolverPfx+ XMLConstants.COLON +attr.getLocalName(), attr.getNodeValue()); } else { attribute(attr.getNamespaceURI(), XMLConstants.EMPTY_STRING, attr.getName(), attr.getNodeValue()); attribute(XMLConstants.XMLNS_URL, XMLConstants.EMPTY_STRING,XMLConstants.XMLNS + XMLConstants.COLON + attr.getPrefix(), attr.getNamespaceURI()); characters(node.getNodeValue()); } else { NodeRecordContentHandler mrcHdlr = new NodeRecordContentHandler(this, namespaceResolver);
public void startPrefixMapping(String prefix, String uri) throws SAXException { String namespaceUri = getNamespaceResolver().resolveNamespacePrefix(prefix); if(namespaceUri == null || !namespaceUri.equals(uri)) { prefixMappings.put(prefix, uri); } }
/** * INTERNAL: */ public void attribute(String namespaceURI, String localName, String qName, String value) { if (node.getNodeType() == Node.ELEMENT_NODE) { ((Element)getDOM()).setAttributeNS(namespaceURI, qName, value); } }
/** * INTERNAL: * Create a record with the element. */ public NodeRecord(Node node) { setDOM(node); }
marshalRecord.flush(); } else if(result instanceof DOMResult) { NodeRecord marshalRecord = new NodeRecord(); marshalRecord.setDOM(((DOMResult)result).getNode()); marshalRecord.setMarshaller(anXMLMarshaller); listener.setRootMarshalRecord(marshalRecord); anXMLMarshaller.marshal(xmlDocument, marshalRecord); marshalRecord.flush(); } else { StringWriter writer = new StringWriter();
NodeRecord contentHandlerRecord = new NodeRecord(node); contentHandlerRecord.setMarshaller(this); if (!isXMLRoot) { if ((null == xmlDescriptor.getDefaultRootElement()) && (node.getNodeType() == Node.ELEMENT_NODE) && (xmlDescriptor.getSchemaReference() != null) && (xmlDescriptor.getSchemaReference().getType() == XMLSchemaReference.COMPLEX_TYPE)) {
/** * INTERNAL: * Convert the given object to an XML Document * @param object the object to marshal * @return the document which the specified object has been marshalled to * @param descriptor the XMLDescriptor for the object being marshalled * @throws XMLMarshalException if an error occurred during marshalling */ protected Document objectToXML(Object object, DESCRIPTOR descriptor, boolean isXMLRoot) throws XMLMarshalException { ABSTRACT_SESSION session = context.getSession(descriptor); MarshalRecord marshalRecord = new NodeRecord(); marshalRecord.setMarshaller(this); marshal(object, marshalRecord, session, descriptor, isXMLRoot); return marshalRecord.getDocument(); }
attribute(attr.getNamespaceURI(), Constants.EMPTY_STRING, resolverPfx+ Constants.COLON +attr.getLocalName(), attr.getNodeValue()); } else { attribute(attr.getNamespaceURI(), Constants.EMPTY_STRING, attr.getName(), attr.getNodeValue()); attribute(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI, Constants.EMPTY_STRING, javax.xml.XMLConstants.XMLNS_ATTRIBUTE + Constants.COLON + attr.getPrefix(), attr.getNamespaceURI()); characters(node.getNodeValue()); } else { NodeRecordContentHandler mrcHdlr = new NodeRecordContentHandler(this, namespaceResolver);
/** * INTERNAL: * Create a record with the element. */ public NodeRecord(Node node) { setDOM(node); getNamespaceResolver().setDOM(node); }
public void startPrefixMapping(String prefix, String uri) throws SAXException { String namespaceUri = getNamespaceResolver().resolveNamespacePrefix(prefix); if(namespaceUri == null || !namespaceUri.equals(uri)) { prefixMappings.put(prefix, uri); } }
/** * INTERNAL: */ public void attribute(String namespaceURI, String localName, String qName, String value) { if (node.getNodeType() == Node.ELEMENT_NODE) { getDOM().setAttributeNS(namespaceURI, qName, value); } }
/** * INTERNAL: * Create a record with the root element name get the namespace URI from the namespaceResolver. */ public NodeRecord(String rootElementName, NamespaceResolver namespaceResolver) { this(); String rootElementNamespaceURI = resolveNamespace(namespaceResolver, rootElementName); Node rootElement = document.createElementNS(rootElementNamespaceURI, rootElementName); document.appendChild(rootElement); setDOM(rootElement); }
/** * Create a new row/record for the object builder with the given name. * This allows subclasses to define different record types. */ public AbstractMarshalRecord createRecord(String rootName, AbstractSession session) { NodeRecord nRec = new NodeRecord(rootName, getNamespaceResolver()); nRec.setSession(session); return nRec; }