|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xml.sax.helpers.DefaultHandler org.xml.sax.ext.DefaultHandler2 org.jboss.dna.graph.xml.XmlHandler
@NotThreadSafe public class XmlHandler
A DefaultHandler2
specialization that responds to XML content events by creating the corresponding content in the
supplied graph. This implementation ignores DTD entities, XML contents, and other XML processing instructions. If other
behavior is required, the appropriate methods can be overridden. (Which is why this class extends DefaultHandler2
,
which has support for processing all the different parts of XML.
This class can be passed to the SAXParser
's parse(..,DefaultHandler)
methods.
Nested Class Summary | |
---|---|
static class |
XmlHandler.AttributeScoping
The choices for how attributes that have no namespace prefix should be assigned a namespace. |
Field Summary | |
---|---|
static XmlHandler.AttributeScoping |
DEFAULT_ATTRIBUTE_SCOPING
The default XmlHandler.AttributeScoping . |
static TextDecoder |
DEFAULT_DECODER
Decoder for XML names, to turn '_xHHHH_' sequences in the XML element and attribute names into the corresponding UTF-16 characters. |
Constructor Summary | |
---|---|
XmlHandler(Destination destination,
boolean skipRootElement,
Path parent,
TextDecoder textDecoder,
Name nameAttribute,
Name typeAttribute,
Name typeAttributeValue,
XmlHandler.AttributeScoping scoping)
Create a handler that creates content in the supplied graph |
Method Summary | |
---|---|
void |
characters(char[] ch,
int start,
int length)
|
void |
endDocument()
|
void |
endElement(String uri,
String localName,
String name)
|
void |
endPrefixMapping(String prefix)
|
void |
startElement(String uri,
String localName,
String name,
Attributes attributes)
|
void |
startPrefixMapping(String prefix,
String uri)
This method ensures that the namespace is registered with the registry , using the supplied prefix
to register the namespace if required. |
Methods inherited from class org.xml.sax.ext.DefaultHandler2 |
---|
attributeDecl, comment, elementDecl, endCDATA, endDTD, endEntity, externalEntityDecl, getExternalSubset, internalEntityDecl, resolveEntity, resolveEntity, startCDATA, startDTD, startEntity |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
---|
error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static TextDecoder DEFAULT_DECODER
public static XmlHandler.AttributeScoping DEFAULT_ATTRIBUTE_SCOPING
XmlHandler.AttributeScoping
.
Constructor Detail |
---|
public XmlHandler(Destination destination, boolean skipRootElement, Path parent, TextDecoder textDecoder, Name nameAttribute, Name typeAttribute, Name typeAttributeValue, XmlHandler.AttributeScoping scoping)
destination
- the destination where the content should be sent.graph in which the content should be placedskipRootElement
- true if the root element of the document should be skipped, or false if the root element should be
converted to the top-level node of the contentparent
- the path to the node in the graph under which the content should be placed; if null, the root node is assumedtextDecoder
- the text decoder that should be used to decode the XML element names and XML attribute names, prior to
using those values to create names; or null if the default encoder should be usednameAttribute
- the name of the property whose value should be used for the names of the nodes (typically, this is
"jcr:name" or something equivalent); or null if the XML element name should always be used as the node nametypeAttribute
- the name of the property that should be set with the type of the XML element, or null if there is no
such propertytypeAttributeValue
- the value of the type property that should be used if the node has no nameAttribute
,
or null if the value should be set to the type of the XML elementscoping
- defines how to choose the namespace of attributes that do not have a namespace prefix; if null, the
DEFAULT_ATTRIBUTE_SCOPING
value is used
IllegalArgumentException
- if the destination reference is nullMethod Detail |
---|
public void startPrefixMapping(String prefix, String uri)
This method ensures that the namespace is registered with the registry
, using the supplied prefix
to register the namespace if required. Note that because this class does not really use the namespace prefixes to create
Name
objects, no attempt is made to match the XML namespace prefixes.
startPrefixMapping
in interface ContentHandler
startPrefixMapping
in class DefaultHandler
DefaultHandler.startPrefixMapping(java.lang.String, java.lang.String)
public void endPrefixMapping(String prefix)
endPrefixMapping
in interface ContentHandler
endPrefixMapping
in class DefaultHandler
DefaultHandler.endPrefixMapping(java.lang.String)
public void startElement(String uri, String localName, String name, Attributes attributes)
startElement
in interface ContentHandler
startElement
in class DefaultHandler
DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String,
org.xml.sax.Attributes)
public void endElement(String uri, String localName, String name)
endElement
in interface ContentHandler
endElement
in class DefaultHandler
DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public void characters(char[] ch, int start, int length)
characters
in interface ContentHandler
characters
in class DefaultHandler
DefaultHandler.characters(char[], int, int)
public void endDocument()
endDocument
in interface ContentHandler
endDocument
in class DefaultHandler
DefaultHandler.endDocument()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |