public Document getInitializedDocument() throws SAXException { if (document == null) { try { document = xmlPlatform.createDocument(); nodes.add(document); } catch (Exception e) { throw new SAXException(e); } } return document; }
/** * Set the XML from an XML reader. */ public void transformFromXML(Reader reader) { XMLParser parser = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLParser(); Document document = parser.parse(reader); setDOM(document.getDocumentElement()); }
private static InputSource createInputSourceFromSource(Source aSource) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); StreamResult result = new StreamResult(baos); XMLTransformer t = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLTransformer(); t.transform(aSource, result); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); InputSource inputSource = new InputSource(bais); inputSource.setSystemId(aSource.getSystemId()); return inputSource; }
public DirectToXMLTypeMapping() { super(); this.xmlTransformer = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLTransformer(); this.xmlTransformer.setFormattedOutput(false); this.xmlParser = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLParser(); this.xmlComparer = new XMLComparer(); }
public String getDefaultNamespaceURI() { if(null != defaultNamespaceURI) { return defaultNamespaceURI; } else if(dom != null) { return XMLPlatformFactory.getInstance().getXMLPlatform().resolveNamespacePrefix(dom, null); } return null; }
public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, AbstractSession executionSession) { Object value = ((DOMRecord)row).getIndicatingNoEntry(this.getField(), true); if (value instanceof Element) { XMLPlatformFactory.getInstance().getXMLPlatform().namespaceQualifyFragment((Element)value); } return value; }
/** * Validate the given object. * @param object A single object to validate * @return true if this is a valid object, otherwise false */ public boolean validate(Object object) throws XMLMarshalException { if (object == null) { throw XMLMarshalException.nullArgumentException(); } try { // Create a new XML Record using the object's class name (not fully qualified) as the root String name = ((XMLDescriptor)xmlContext.getSession(object).getDescriptor(object)).getDefaultRootElement(); if (name == null) { String qualifiedName = object.getClass().getName(); int idx = qualifiedName.lastIndexOf('.'); name = qualifiedName.substring(idx + 1); } XMLDescriptor descriptor = marshaller.getDescriptor(object); XMLRoot root = new XMLRoot(); root.setObject(object); root.setLocalName(name); XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); Document doc = xmlPlatform.createDocument(); marshaller.marshal(root, doc); return xmlPlatform.validate(doc.getDocumentElement(), descriptor, getErrorHandler()); } catch (XMLPlatformException e) { throw XMLMarshalException.validateException(e); } }
private XMLParser getXMLParser() { if (xmlParser == null || shouldReset) { XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); xmlPlatform.setDisableSecureProcessing(isSecureProcessingDisabled()); xmlParser = xmlPlatform.newXMLParser(); xmlParser.setNamespaceAware(true); if (null != errorHandler) { xmlParser.setErrorHandler(errorHandler); } if (null != entityResolver) { xmlParser.setEntityResolver(entityResolver); } xmlParser.setValidationMode(validationMode); xmlParser.setWhitespacePreserving(isWhitespacePreserving); shouldReset = false; } return xmlParser; }
UnmarshallerHandler handler = this.xmlUnmarshaller.getUnmarshallerHandler(); XMLPlatform xmlPlat = XMLPlatformFactory.getInstance().getXMLPlatform(); xmlPlat.setDisableSecureProcessing(isSecureProcessingDisabled()); XMLTransformer transformer = xmlPLatform.newXMLTransformer(); SAXResult result = new SAXResult(handler); transformer.transform(source, result);
public boolean isValid(Document document, ErrorHandler errorHandler) { try { XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); return xmlPlatform.validateDocument(document, getURL(), errorHandler); } catch (XMLPlatformException e) { if (e.getErrorCode() == XMLPlatformException.XML_PLATFORM_PARSER_ERROR_RESOLVING_XML_SCHEMA) { throw XMLMarshalException.errorResolvingXMLSchema(e); } else { return false; } } }
public NodeList selectNodes(Node contextNode, XML_FIELD xmlField, XMLNamespaceResolver xmlNamespaceResolver, AbstractNullPolicy nullPolicy, boolean omitText, boolean concatinateTextNodes) { try { if (contextNode == null) { return null; } XPathFragment xPathFragment = xmlField.getXPathFragment(); // allow the platform to handle the advanced case if (xPathFragment.shouldExecuteSelectNodes()) { return xmlPlatform.selectNodesAdvanced(contextNode, xmlField.getXPath(), xmlNamespaceResolver); } return selectNodes(contextNode, xPathFragment, xmlNamespaceResolver, nullPolicy, omitText, concatinateTextNodes); } catch (Exception x) { throw XMLMarshalException.invalidXPathString(xmlField.getXPath(), x); } }
return xmlPlatform.selectSingleNodeAdvanced(contextNode, xmlField.getXPath(), xmlNamespaceResolver);
public String resolveNamespacePrefix(String prefix) { XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); return xmlPlatform.resolveNamespacePrefix(currentNode, prefix); }
public DirectToXMLTypeMapping() { super(); this.xmlTransformer = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLTransformer(); this.xmlTransformer.setFormattedOutput(false); this.xmlParser = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLParser(); this.xmlComparer = new XMLComparer(); }
public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey cacheKey, AbstractSession executionSession, boolean isTargetProtected, Boolean[] wasCacheUsed) { DOMRecord domRecord = (DOMRecord) row; Object value = domRecord.getIndicatingNoEntry(this.getField(), true); if(value == domRecord) { value = domRecord.getDOM(); } if (value instanceof Element) { XMLPlatformFactory.getInstance().getXMLPlatform().namespaceQualifyFragment((Element)value); } return value; }
/** * Validate the given object. * @param object A single object to validate * @return true if this is a valid object, otherwise false */ public boolean validate(Object object) throws XMLMarshalException { if (object == null) { throw XMLMarshalException.nullArgumentException(); } try { // Create a new XML Record using the object's class name (not fully qualified) as the root String name = ((XMLDescriptor)xmlContext.getSession(object).getDescriptor(object)).getDefaultRootElement(); if (name == null) { String qualifiedName = object.getClass().getName(); int idx = qualifiedName.lastIndexOf('.'); name = qualifiedName.substring(idx + 1); } XMLDescriptor descriptor = marshaller.getDescriptor(object); Root root = new Root(); root.setObject(object); root.setLocalName(name); XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); Document doc = xmlPlatform.createDocument(); marshaller.marshal(root, doc); return xmlPlatform.validate(doc.getDocumentElement(), descriptor, getErrorHandler()); } catch (XMLPlatformException e) { throw XMLMarshalException.validateException(e); } }
private XMLParser getParser() { if (parser == null || shouldReset) { XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); xmlPlatform.setDisableSecureProcessing(isSecureProcessingDisabled()); parser = xmlPlatform.newXMLParser(parserFeatures); parser.setNamespaceAware(true); if (errorHandler != null) { parser.setErrorHandler(errorHandler); } if (entityResolver != null) { parser.setEntityResolver(entityResolver); } if (schemas != null) { try { parser.setXMLSchemas(schemas); } catch (XMLPlatformException e) { throw XMLMarshalException.errorSettingSchemas(e, schemas); } } if (schema != null) { parser.setXMLSchema(schema); } parser.setValidationMode(validationMode); parser.setWhitespacePreserving(isWhitespacePreserving); shouldReset = false; } return parser; }
public boolean isValid(Document document, ErrorHandler errorHandler) { try { XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform(); return xmlPlatform.validateDocument(document, getURL(), errorHandler); } catch (XMLPlatformException e) { if (e.getErrorCode() == XMLPlatformException.XML_PLATFORM_PARSER_ERROR_RESOLVING_XML_SCHEMA) { throw XMLMarshalException.errorResolvingXMLSchema(e); } else { return false; } } }
public NodeList selectNodes(Node contextNode, XML_FIELD xmlField, XMLNamespaceResolver xmlNamespaceResolver, AbstractNullPolicy nullPolicy, boolean omitText, boolean concatinateTextNodes) { try { if (contextNode == null) { return null; } XPathFragment xPathFragment = xmlField.getXPathFragment(); // allow the platform to handle the advanced case if (xPathFragment.shouldExecuteSelectNodes()) { return xmlPlatform.selectNodesAdvanced(contextNode, xmlField.getXPath(), xmlNamespaceResolver); } return selectNodes(contextNode, xPathFragment, xmlNamespaceResolver, nullPolicy, omitText, concatinateTextNodes); } catch (Exception x) { throw XMLMarshalException.invalidXPathString(xmlField.getXPath(), x); } }
return xmlPlatform.selectSingleNodeAdvanced(contextNode, xmlField.getXPath(), xmlNamespaceResolver);