Class DOMResource
java.lang.Object
de.wwu.scdh.annotation.selection.resource.DOMResource
- All Implemented Interfaces:
Resource<net.sf.saxon.s9api.XdmNode>,S9ApiResource<net.sf.saxon.s9api.XdmNode>
- Direct Known Subclasses:
MappedDOMResource
A
DOMResource is a web Resource that can be parsed
to a DOM representation, e.g., an HTML or an XML document.-
Constructor Summary
ConstructorsConstructorDescriptionDOMResource(URI uri, Source source, net.sf.saxon.s9api.Processor processor) Create a newDOMResourcefrom a parsed JAXPSource.DOMResource(URI uri, net.sf.saxon.s9api.XdmNode document, net.sf.saxon.s9api.Processor processor) Create a newDOMResource. -
Method Summary
Modifier and TypeMethodDescriptionstatic DOMResourcefromHTML(URI uri, InputStream inputStream, String systemId, net.sf.saxon.s9api.Processor processor) Make aDOMResourcefrom HTML input given as anInputStream.static DOMResourceSame asfromHTML(URI, InputStream, String, Processor), but gets the input from the URI.static DOMResourcefromXML(URI uri, InputStream inputStream, String systemId, net.sf.saxon.s9api.Processor processor) Make aDOMResourcefrom XML input given as anInputStream.static DOMResourceSame asfromXML(URI, InputStream, String, Processor), but gets the input from the URI.static DOMResourcefromXMLwithXerces(URI uri, InputStream inputStream, String systemId, net.sf.saxon.s9api.Processor processor) Make aMappedDOMResourcefrom XML input given as anInputStreamusing the Xerces DOM parser.static DOMResourcefromXMLwithXerces(URI uri, net.sf.saxon.s9api.Processor processor) Same asfromXMLwithXerces(URI, InputStream, String, Processor), but gets the input from the URI.net.sf.saxon.s9api.XdmNodeReturns the document node of the DOM resource.net.sf.saxon.s9api.ProcessorReturns the SaxonProcessorthe resource was parsed with.getUri()Returns theURIidentifying this resource.
-
Constructor Details
-
DOMResource
public DOMResource(URI uri, net.sf.saxon.s9api.XdmNode document, net.sf.saxon.s9api.Processor processor) Create a newDOMResource.- Parameters:
uri- aURIidentifying the resourcedocument- the document node (root node)processor- a saxonProcessorthat was used by the document builder
-
DOMResource
public DOMResource(URI uri, Source source, net.sf.saxon.s9api.Processor processor) throws net.sf.saxon.s9api.SaxonApiException Create a newDOMResourcefrom a parsed JAXPSource. The source is fed to Saxon'sDocumentBuilder. Please notice the information on JAXP source types in the Saxon documentation. Theuriis notsystemId: ThesystemIdis related to the physical location of the source and may be important for processing XIncludes or the like and determines the Base URI of the resulting nodes of the document. It should be set to the source, if required. In contrast, theurimust be seen as the IRI of the resource in a linked open data context. It is used to filter out selectors into the resource.
-
-
Method Details
-
fromHTML
public static DOMResource fromHTML(URI uri, InputStream inputStream, String systemId, net.sf.saxon.s9api.Processor processor) throws net.sf.saxon.s9api.SaxonApiException Make aDOMResourcefrom HTML input given as anInputStream. This uses the Cowan'sParserfor parsing the HTML input, which may be tag soup.- Parameters:
uri- - aURIidentifying the resource in a linked open data contextinputStream- -InputStreamwith the HTML documentsystemId- - the physical location of the input stream, may be used for processing XIncludesprocessor- a SaxonProcessorto be used by the document builder- Throws:
net.sf.saxon.s9api.SaxonApiException- when the document builder fails
-
fromHTML
public static DOMResource fromHTML(URI uri, net.sf.saxon.s9api.Processor processor) throws IOException, net.sf.saxon.s9api.SaxonApiException Same asfromHTML(URI, InputStream, String, Processor), but gets the input from the URI.- Parameters:
uri- - aURIidentifying the resourceprocessor- - a SaxonProcessorto be used by the document builder- Throws:
net.sf.saxon.s9api.SaxonApiException- when the document builder failsIOException
-
fromXML
public static DOMResource fromXML(URI uri, InputStream inputStream, String systemId, net.sf.saxon.s9api.Processor processor) throws net.sf.saxon.s9api.SaxonApiException Make aDOMResourcefrom XML input given as anInputStream.- Parameters:
uri- - aURIidentifying the resourceinputStream- -InputStreamwith the XML documentsystemId- - the systemId of the input stream, may be used to process XIncludesprocessor- - a SaxonProcessorto be used by the document builder- Throws:
net.sf.saxon.s9api.SaxonApiException- when the document builder fails
-
fromXML
public static DOMResource fromXML(URI uri, net.sf.saxon.s9api.Processor processor) throws IOException, net.sf.saxon.s9api.SaxonApiException Same asfromXML(URI, InputStream, String, Processor), but gets the input from the URI.- Parameters:
uri- - aURIidentifying the resourceprocessor- - a SaxonProcessorto be used by the document builder- Throws:
net.sf.saxon.s9api.SaxonApiException- when the document builder failsIOException
-
fromXMLwithXerces
public static DOMResource fromXMLwithXerces(URI uri, InputStream inputStream, String systemId, net.sf.saxon.s9api.Processor processor) throws ResourceException Make aMappedDOMResourcefrom XML input given as anInputStreamusing the Xerces DOM parser. The parsed document is wrapped in XDM nodes, but the underlying nodes arew3c.xml.domnodes.- Parameters:
uri- - aURIidentifying the resourceinputStream- -InputStreamwith the XML documentsystemId- - the systemId of the input stream, may be used to process XIncludesprocessor- - a SaxonProcessorto be used by the document builder- Throws:
ResourceException- when the document builder fails
-
fromXMLwithXerces
public static DOMResource fromXMLwithXerces(URI uri, net.sf.saxon.s9api.Processor processor) throws ResourceException Same asfromXMLwithXerces(URI, InputStream, String, Processor), but gets the input from the URI.- Parameters:
uri- aURIidentifying the resourceprocessor- - a sSaxonProcessorto be used by the document builder- Throws:
ResourceException- when the document builder fails
-
getUri
Returns theURIidentifying this resource. -
getContents
public net.sf.saxon.s9api.XdmNode getContents()Returns the document node of the DOM resource.- Specified by:
getContentsin interfaceResource<net.sf.saxon.s9api.XdmNode>- Returns:
- an
XdmNode
-
getProcessor
public net.sf.saxon.s9api.Processor getProcessor()Returns the SaxonProcessorthe resource was parsed with.- Specified by:
getProcessorin interfaceS9ApiResource<net.sf.saxon.s9api.XdmNode>- Returns:
- a Saxon
Processor
-