Package mondrian.tui
Class XmlUtil
java.lang.Object
mondrian.tui.XmlUtil
Some XML parsing, validation and transform utility methods used
to valiate XMLA responses.
- Author:
- Richard M. Emberson
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This can be extened to have a map from publicId/systemId to InputSource.static class
Error handler plus helper methods. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
This is used to get a Document's namespace attribute value.static org.apache.xerces.parsers.DOMParser
getParser
(String schemaLocationPropertyValue, EntityResolver entityResolver, boolean validate) Get your non-cached DOM parser which can be configured to do schema based validation of the instance Document.static final String
getSoapXmlaXds2xd
(String xmlaPrefix) This is the xslt that can extract the "data" part of a SOAP XMLA response.static final String
getSoapXmlaXds2xs
(String xmlaPrefix) This is the xslt that can extract the "schema" part of a SOAP XMLA response.static TransformerFactory
static String
Get the Xerces version being used.static int[]
Gets the Xerces version numbers as a three part array of ints where the first element is the major release number, the second is the minor release number, and the third is the patch number.static String
Get the number part of the Xerces Version string.static final String
getXmlaXds2xd
(String ns) This is the xslt that can extract the "data" part of a XMLA response.static final String
getXmlaXds2xs
(String ns) This is the xslt that can extract the "schema" part of a XMLA response.static String
static String
makeRootPathInSoapBody
(String xmlaPrefix, String xsdPrefix) static Document
newDocument
(Node firstElement, boolean deepcopy) static Document
parse
(byte[] bytes) Parse a byte array into a Document (no validation).static Document
static Document
parse
(InputStream in) Parse a stream into a Document (no validation).static Document
Parse a String into a Document (no validation).static Node[]
static boolean
Returns whether the XML parser supports validation.static String
Convert a Node to a String.static Node
static Node
Transform a Document and return the transformed Node.static Node
static Node
Transform a Document and return the transformed Node.static void
validate
(String docStr, String schemaLocationPropertyValue, EntityResolver resolver) static void
validate
(Document doc, String schemaLocationPropertyValue, EntityResolver resolver)
-
Field Details
-
LINE_SEP
-
SOAP_PREFIX
- See Also:
-
XSD_PREFIX
- See Also:
-
XMLNS
- See Also:
-
NAMESPACES_FEATURE_ID
- See Also:
-
VALIDATION_FEATURE_ID
- See Also:
-
SCHEMA_VALIDATION_FEATURE_ID
- See Also:
-
FULL_SCHEMA_VALIDATION_FEATURE_ID
- See Also:
-
DEFER_NODE_EXPANSION
- See Also:
-
SCHEMA_LOCATION
- See Also:
-
-
Method Details
-
getSoapXmlaXds2xd
This is the xslt that can extract the "data" part of a SOAP XMLA response. -
getSoapXmlaXds2xs
This is the xslt that can extract the "schema" part of a SOAP XMLA response. -
getXmlaXds2xd
This is the xslt that can extract the "data" part of a XMLA response. -
getXmlaXds2xs
This is the xslt that can extract the "schema" part of a XMLA response. -
newDocument
-
getParser
public static org.apache.xerces.parsers.DOMParser getParser(String schemaLocationPropertyValue, EntityResolver entityResolver, boolean validate) throws SAXNotRecognizedException, SAXNotSupportedException Get your non-cached DOM parser which can be configured to do schema based validation of the instance Document. -
parseString
Parse a String into a Document (no validation).- Throws:
SAXException
IOException
-
parse
Parse a byte array into a Document (no validation).- Throws:
SAXException
IOException
-
parse
- Throws:
SAXException
IOException
-
parse
Parse a stream into a Document (no validation).- Throws:
SAXException
IOException
-
makeRootPathInSoapBody
-
makeRootPathInSoapBody
-
selectAsNodes
public static Node[] selectAsNodes(Node node, String xpathExp, Map<String, String> namespaceMap) throws XPathException- Throws:
XPathException
-
toString
Convert a Node to a String. -
getXercesVersion
Get the Xerces version being used.- Returns:
- Xerces version being used
-
getXercesVersionNumberString
Get the number part of the Xerces Version string.- Returns:
- number part of the Xerces Version string
-
getXercesVersionNumbers
public static int[] getXercesVersionNumbers()Gets the Xerces version numbers as a three part array of ints where the first element is the major release number, the second is the minor release number, and the third is the patch number.- Returns:
- Xerces version number as int array
-
supportsValidation
public static boolean supportsValidation()Returns whether the XML parser supports validation.I could not get validation to work with Xerces 2.2 so I put in this check. If you want to test on an earlier version of Xerces simply define the above property: "mondrian.xml.always.attempt.validation", to true.
- Returns:
- whether the XML parser supports validation
-
validate
public static void validate(Document doc, String schemaLocationPropertyValue, EntityResolver resolver) throws IOException, SAXException - Throws:
IOException
SAXException
-
validate
public static void validate(String docStr, String schemaLocationPropertyValue, EntityResolver resolver) throws IOException, SAXException - Throws:
IOException
SAXException
-
getNamespaceAttributeValue
This is used to get a Document's namespace attribute value. -
getTransformerFactory
public static TransformerFactory getTransformerFactory() throws TransformerFactoryConfigurationError -
transform
public static Node transform(Document inDoc, String xslFileName, String[][] namevalueParameters) throws ParserConfigurationException, SAXException, IOException, TransformerConfigurationException, TransformerException Transform a Document and return the transformed Node. -
transform
public static Node transform(Document inDoc, String xslFileName) throws ParserConfigurationException, SAXException, IOException, TransformerConfigurationException, TransformerException -
transform
public static Node transform(Document inDoc, Reader xslReader, String[][] namevalueParameters) throws ParserConfigurationException, SAXException, IOException, TransformerConfigurationException, TransformerException Transform a Document and return the transformed Node. -
transform
public static Node transform(Document inDoc, Reader xslReader) throws ParserConfigurationException, SAXException, IOException, TransformerConfigurationException, TransformerException
-