|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.infinityloop.util.markup.XMLTools
public class XMLTools
Tools for XML parsing and XSLT application.
| Field Summary | |
|---|---|
static int |
kProfilePassAll
Profile constant for passing all characters unchanged. |
static int |
kProfileXML10
Profile constant for passing only characters that are valid XML 1.0. |
| Constructor Summary | |
|---|---|
XMLTools()
|
|
| Method Summary | |
|---|---|
static void |
addCatalog(java.lang.String catalogLocation)
adds a single catalog to the existing catalog system |
static org.w3c.dom.Node |
appendChildren(org.w3c.dom.Node dest,
org.w3c.dom.Node src)
Appends all children(!) |
static void |
chainSaxon6(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
OutputProxy outXML,
java.util.ArrayList transformations)
chains several transformationsone one after another. |
static void |
chainSaxon9B(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
OutputProxy outXML,
java.util.ArrayList transformations)
chains several transformationsone one after another. |
static void |
chainSaxon9BWithIntermediates(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
OutputProxy outXML,
java.util.ArrayList transformations,
java.lang.String intermediateDir)
chains several transformationsone one after another. |
static void |
chainXalan(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
OutputProxy outXML,
java.util.ArrayList transformations)
chains several transformationsone one after another. |
static void |
chainXalanWithIntermediates(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
OutputProxy outXML,
java.util.ArrayList transformations,
java.lang.String intermediateDir)
chains several transformationsone one after another. |
static void |
checkWellformedness(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy theFile)
Perform validation against a DTD using Xerces. |
static java.lang.String |
collectTextNodesContent(org.w3c.dom.DocumentFragment df)
Collect text-only contents on this DocumentFragment, possibly with filter on element names |
static java.lang.String |
collectTextNodesContent(org.w3c.dom.Node curNode,
de.infinityloop.upcast.util.namespace.QualifiedNameList elementFilter)
Collect text-only contents on this Node, possibly with filter on element names. |
static org.xml.sax.InputSource |
createInputSource(InputProxy ip)
Creates a StreamSource object from the passed proxy. |
static void |
discardCatalogs()
removes all registered catalogs from the system |
static java.util.List |
evaluateXPathCustom(de.infinityloop.upcast.util.namespace.NamespaceManager nsContext,
org.jaxen.XPath expression,
org.w3c.dom.Node context)
Select nodes (starting at the specified context node) matching the specified XPath expression |
static java.util.List |
evaluateXPathDOM(de.infinityloop.upcast.util.namespace.NamespaceManager nsContext,
org.w3c.dom.Node context,
java.lang.String xpath)
Select nodes (starting at the specified context node) matching the specified XPath expression |
static void |
executeSaxon6(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
InputProxy inXSL,
java.util.Map parameters,
OutputProxy outXML)
Run a single transformation in Saxon 6. |
static void |
executeSaxon9B(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
InputProxy inXSL,
java.util.Map parameters,
OutputProxy outXML)
Run a single transformation in Saxon 9B. |
static void |
executeXalan(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
InputProxy inXSL,
java.util.Map parameters,
OutputProxy outXML)
Run a single transformation in Saxon. |
static org.w3c.dom.Text |
findFirstTextNodeStartingWith(org.w3c.dom.Node curNode,
java.lang.String prefix,
de.infinityloop.upcast.util.namespace.QualifiedNameList elementFilter)
Finds the first (probably depth-first child-) TextNode and checks if it starts with the specified string. |
static org.w3c.dom.Element |
findNamedAncestor(de.infinityloop.upcast.util.namespace.QualifiedName ancestorName,
org.w3c.dom.Element elem)
Finds the first named ancestor element of the element passed. |
static org.w3c.dom.Element |
findNamedAncestorOrSelf(de.infinityloop.upcast.util.namespace.QualifiedName ancestorName,
org.w3c.dom.Element elem)
Finds the first named ancestor-or-self element of the element passed. |
static org.xml.sax.EntityResolver |
getGlobalEntityResolver()
retrieves the global default entity resolver class. |
static java.util.Vector |
getRegisteredCatalogSearchPaths()
Returns a Vector of all currently programmatically registered Catalog file search paths (does not include Catalogs set by the xml.catalog.files system property!). |
static java.lang.String |
getXSLTProcessorVersionString(java.lang.String processorToUse)
Get current XSLT processor used + version String |
static void |
initializeCatalogs(java.util.Vector additionalFiles)
initializes the default catalog handler, with adding the catalog files as in the passed Vector of String objects. |
static void |
insertFragmentFromSource(de.infinityloop.util.markup.DOMCreatorHandler.BuildingMode where,
org.w3c.dom.Node target,
InputProxy source,
de.infinityloop.upcast.util.namespace.NamespaceManager destNSM)
Inserts the parsed XML source as DOM nodes relative to the specified target node using the specified nsmanager to add or retrieve mapping names for existing namespaces. |
static java.lang.String |
makePCDATA_XML(java.lang.String pcdata)
Turns the passed PCDATA content into a string for writing to UTF-8 XML file, using entities where necessary. |
static java.lang.String |
makePCDATAAttr_XML(java.lang.String pcdata)
Turns the passed PCDATA content into a string for writing to UTF8 XML file, using entities where necessary. |
static java.lang.String |
makeValidXML_ID(java.lang.String src)
Transform a passed string in such a way that the result conforms to the rules for an XML 1.0 'Name' (as used e.g. for element names or xml:id). |
static java.lang.String |
makeValidXMLName(java.lang.String src)
Transform a passed string in such a way that the result conforms to the rules for an XML 1.0 'Name' (as used e.g. for element names or xml:id). |
static boolean |
matchNode(org.w3c.dom.Node inNode,
de.infinityloop.upcast.util.namespace.QualifiedNameList elementFilter)
Tests if the passed node is filtered by the elementFilter QualifiedNameList. |
static void |
moveChildren(org.w3c.dom.Node from,
org.w3c.dom.Node to)
Moves all children of the first node to the second node. |
static org.w3c.dom.Document |
parseDOM(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy ip)
DOM-parses the passed file and returns a constructed DOM. |
static void |
parseSAX(de.infinityloop.util.markup.XMLProcessingConfiguration config,
org.w3c.dom.Document inTree,
java.lang.String baseURL)
Parses not from XML, but from a DOM tree, into SAX events. |
static void |
parseSAX(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy ip)
SAX-parses the passed file, driving any specified handlers in the configuration |
static void |
removeChildren(org.w3c.dom.Node node)
Removes all children of the specified node |
static void |
removeNodeOnly(org.w3c.dom.Node node)
Removes (only) the specified node from the tree, but not its children. |
static void |
removeNodeWithSubtree(org.w3c.dom.Node node)
Removes the specified node (including its subtree) from the tree. |
static void |
serializeDOM(org.w3c.dom.Document src,
OutputProxy dest)
serializes a DOM tree to the specified OutputProxy. |
static void |
serializeInternalDOM(org.w3c.dom.Document src,
OutputProxy dest)
serializes an internal upCast DOM tree to the specified OutputProxy. |
static void |
serializeNode(org.w3c.dom.Node n,
boolean children,
java.io.Writer w)
serializes an internal upCast DOM node to the specified OutputProxy. |
static java.lang.String |
serializeNodeToString(org.w3c.dom.Node n,
boolean children)
Serializes a subtree of the DOM to a string for debugging output. |
static void |
setGlobalEntityResolver(org.xml.sax.EntityResolver er)
sets a global default entity resolver class. |
static java.lang.String |
stripInvalidCharacters(int profile,
java.lang.String src)
Completely strips characters from the passed string based on the passed profile ID. |
static void |
validateAgainstDTD(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy theFile)
Perform validation against a DTD using Xerces. |
static void |
validateAgainstRelaxNG(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy theFile,
InputProxy schemaFile,
boolean compactSyntax)
Perform validation against a Relax NG Schema using Jing. |
static void |
validateAgainstXMLSchema(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy theFile)
Perform validation against an XML Schema using Xerces. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int kProfilePassAll
public static final int kProfileXML10
| Constructor Detail |
|---|
public XMLTools()
| Method Detail |
|---|
public static void setGlobalEntityResolver(org.xml.sax.EntityResolver er)
public static org.xml.sax.EntityResolver getGlobalEntityResolver()
public static void initializeCatalogs(java.util.Vector additionalFiles)
public static void addCatalog(java.lang.String catalogLocation)
public static void discardCatalogs()
public static void parseSAX(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy ip)
throws org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
public static void parseSAX(de.infinityloop.util.markup.XMLProcessingConfiguration config,
org.w3c.dom.Document inTree,
java.lang.String baseURL)
throws org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
public static org.w3c.dom.Document parseDOM(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy ip)
throws org.xml.sax.SAXException,
java.io.IOException,
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
public static void insertFragmentFromSource(de.infinityloop.util.markup.DOMCreatorHandler.BuildingMode where,
org.w3c.dom.Node target,
InputProxy source,
de.infinityloop.upcast.util.namespace.NamespaceManager destNSM)
throws org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
target - source - destNSM -
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
public static void executeSaxon9B(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
InputProxy inXSL,
java.util.Map parameters,
OutputProxy outXML)
throws java.lang.Exception
config - the processing environment configurationinXML - inXSL - parameters - outXML -
java.lang.Exception
public static void executeSaxon6(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
InputProxy inXSL,
java.util.Map parameters,
OutputProxy outXML)
throws java.lang.Exception
config - the processing environment configurationinXML - inXSL - parameters - outXML -
java.lang.Exception
public static void executeXalan(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
InputProxy inXSL,
java.util.Map parameters,
OutputProxy outXML)
throws java.lang.Exception
config - the processing environment configurationinXML - inXSL - parameters - outXML -
java.lang.Exception
public static void chainXalan(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
OutputProxy outXML,
java.util.ArrayList transformations)
throws java.lang.Exception
config - the configuration to use for initial and possibly final parsing/processing/serializinginXML - source XMLoutXML - destination filetransformations - ArrayList of TransformationChainElement objects
java.lang.Exception
public static void chainSaxon9BWithIntermediates(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
OutputProxy outXML,
java.util.ArrayList transformations,
java.lang.String intermediateDir)
throws java.lang.Exception
features - These features are set for the initial reading of the XML sourceproperties - These properties are set for the initial reading of the XML sourceintermediateDir - directory where intermediate files should be written; when null, transformations are internally chained
java.lang.Exception
public static void chainXalanWithIntermediates(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
OutputProxy outXML,
java.util.ArrayList transformations,
java.lang.String intermediateDir)
throws java.lang.Exception
features - These features are set for the initial reading of the XML sourceproperties - These properties are set for the initial reading of the XML sourceintermediateDir - directory where intermediate files should be written; when null, transformations are internally chained
java.lang.Exception
public static void chainSaxon9B(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
OutputProxy outXML,
java.util.ArrayList transformations)
throws java.lang.Exception
config - the configuration to use for initial and possibly final parsing/processing/serializinginXML - source XMLoutXML - destination filetransformations - ArrayList of TransformationChainElement objects
java.lang.Exception
public static void chainSaxon6(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy inXML,
OutputProxy outXML,
java.util.ArrayList transformations)
throws java.lang.Exception
config - the configuration to use for initial and possibly final parsing/processing/serializinginXML - source XMLoutXML - destination filetransformations - ArrayList of TransformationChainElement objects
java.lang.Exception
public static void serializeInternalDOM(org.w3c.dom.Document src,
OutputProxy dest)
throws java.lang.Exception
src - the Document to serializedest - the destination to serialize to
java.lang.Exception
public static java.lang.String serializeNodeToString(org.w3c.dom.Node n,
boolean children)
n - the start nodechildren - include children?
public static void serializeNode(org.w3c.dom.Node n,
boolean children,
java.io.Writer w)
throws java.lang.Exception
n - the node to (start) serializechildren - when true, all the nodes descendants are also serializedw - the Writer to serialize to
java.lang.Exception
public static void serializeDOM(org.w3c.dom.Document src,
OutputProxy dest)
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.String collectTextNodesContent(org.w3c.dom.DocumentFragment df)
public static boolean matchNode(org.w3c.dom.Node inNode,
de.infinityloop.upcast.util.namespace.QualifiedNameList elementFilter)
!matchNode( n, filter).
To filter for text nodes, use the literal local name #text (in the null namespace).
inNode - the node to testelementFilter - the element filter or null, in which case this method returns false.
public static java.lang.String collectTextNodesContent(org.w3c.dom.Node curNode,
de.infinityloop.upcast.util.namespace.QualifiedNameList elementFilter)
public static org.w3c.dom.Text findFirstTextNodeStartingWith(org.w3c.dom.Node curNode,
java.lang.String prefix,
de.infinityloop.upcast.util.namespace.QualifiedNameList elementFilter)
curNode - the node to start the search with. This node is already considered itselfprefix - the prefix string to match againstelementFilter - a list of element names that should be skipped when searching for an appropriate text node
public static java.util.List evaluateXPathDOM(de.infinityloop.upcast.util.namespace.NamespaceManager nsContext,
org.w3c.dom.Node context,
java.lang.String xpath)
context - the context nodexpath - the xpath expression
public static java.util.List evaluateXPathCustom(de.infinityloop.upcast.util.namespace.NamespaceManager nsContext,
org.jaxen.XPath expression,
org.w3c.dom.Node context)
throws java.lang.Exception
context - the context node
java.lang.Exceptionpublic static java.util.Vector getRegisteredCatalogSearchPaths()
public static java.lang.String makePCDATAAttr_XML(java.lang.String pcdata)
public static java.lang.String makePCDATA_XML(java.lang.String pcdata)
public static java.lang.String getXSLTProcessorVersionString(java.lang.String processorToUse)
processorToUse - identifies the processor for which the version string should be built: "xalan" (the default when null) or "saxon".
public static org.w3c.dom.Element findNamedAncestor(de.infinityloop.upcast.util.namespace.QualifiedName ancestorName,
org.w3c.dom.Element elem)
ancestorName - the name of the ancestor element to look forelem - the start element
public static org.w3c.dom.Element findNamedAncestorOrSelf(de.infinityloop.upcast.util.namespace.QualifiedName ancestorName,
org.w3c.dom.Element elem)
ancestorName - the name of the ancestor-or-self element to look forelem - the start element
public static void removeNodeWithSubtree(org.w3c.dom.Node node)
throws java.lang.Exception
node - the node to be deleted from the tree
java.lang.Exception
public static void removeChildren(org.w3c.dom.Node node)
throws java.lang.Exception
node - the node to delete the children from
java.lang.Exception
public static void removeNodeOnly(org.w3c.dom.Node node)
throws java.lang.Exception
node - the node to remove from the tree
java.lang.Exception
public static void moveChildren(org.w3c.dom.Node from,
org.w3c.dom.Node to)
throws java.lang.Exception
from - the node from which the children should be movedto - the node to which the children are moved
java.lang.Exceptionpublic static org.xml.sax.InputSource createInputSource(InputProxy ip)
ip - the source InputProxy
java.lang.Exceptionpublic static final java.lang.String makeValidXML_ID(java.lang.String src)
makeValidXMLName(), but additionally allows the colon character ':' .
Important Note: This method does not guarantee that for different source
strings the output will be different as well! For example, both 1elem and _1elem will be converted
to _1elem: The first will be modified by prepending a '_', while the second is already a valid
XML Name and therefore passed unchanged.
src - the source string
Name production.public static java.lang.String makeValidXMLName(java.lang.String src)
:'
will not be allowed by this function, as it has special meaning in XML Namespaces. Therefore, consider
the passed string as only the local name of an element.
Important Note: This method does not guarantee that for different source
strings the output will be different as well! For example, both 1elem and _1elem will be converted
to _1elem: The first will be modified by prepending a '_', while the second is already a valid
XML Name and therefore passed unchanged.
src - the source string
Name production.
public static java.lang.String stripInvalidCharacters(int profile,
java.lang.String src)
profile - the profile ID: kProfilePassAll (0): no filtering, kProfileXML (1): filtering according to XML 1.0src - the string to examine and process
public static org.w3c.dom.Node appendChildren(org.w3c.dom.Node dest,
org.w3c.dom.Node src)
dest - the node to append to as childrensrc - the node whose children should be appended
public static void checkWellformedness(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy theFile)
throws org.xml.sax.SAXException
config - in -
org.xml.sax.SAXException
public static void validateAgainstDTD(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy theFile)
throws org.xml.sax.SAXException
config - in -
org.xml.sax.SAXException
public static void validateAgainstXMLSchema(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy theFile)
throws org.xml.sax.SAXException
config - in -
org.xml.sax.SAXException
public static void validateAgainstRelaxNG(de.infinityloop.util.markup.XMLProcessingConfiguration config,
InputProxy theFile,
InputProxy schemaFile,
boolean compactSyntax)
throws org.xml.sax.SAXException
config - theFile - the file to validateschemaFile - the relax ng schema filein -
org.xml.sax.SAXException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||