|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openide.xml.XMLUtil
Utility class collecting library methods related to XML processing.
Method Summary | |
static Document |
createDocument(String rootQName,
String namespaceURI,
String doctypePublicID,
String doctypeSystemID)
Creates empty DOM Document using JAXP factoring. |
static XMLReader |
createXMLReader()
|
static XMLReader |
createXMLReader(boolean validate)
|
static XMLReader |
createXMLReader(boolean validate,
boolean namespaceAware)
Factory SAX XMLReader using JAXP. |
static byte[] |
fromHex(char[] hex,
int start,
int len)
Decodes data encoded using toHex . |
static Document |
parse(InputSource input,
boolean validate,
boolean namespaceAware,
ErrorHandler errorHandler,
EntityResolver entityResolver)
Factory a DocumentBuilder and let it create a org.w3c.dom.Document. |
static String |
toAttributeValue(String val)
Escape passed string as XML attibute value ( < , & , ' and "
will be escaped. |
static String |
toElementContent(String val)
Escape passed string as XML element content ( < ,
& and > |
static String |
toHex(byte[] val,
int start,
int len)
Can be used to encode values that contain invalid XML characters. |
static void |
write(Document doc,
OutputStream out,
String enc)
Write Document into OutputStream using given encoding. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static XMLReader createXMLReader() throws SAXException
createXMLReader(false, false);
public static XMLReader createXMLReader(boolean validate) throws SAXException
validate
- if true validating parser is returnedcreateXMLReader(validate, false);
public static XMLReader createXMLReader(boolean validate, boolean namespaceAware) throws SAXException
validate
- if true validating parser is returnedns
- if true namespace aware parser is returnedpublic static Document createDocument(String rootQName, String namespaceURI, String doctypePublicID, String doctypeSystemID) throws DOMException
Document doc = createDocument("book",null,null,null);
creates new DOM of a well-formed document with root element named book.
rootQName
- qualified name of root element. e.g. myroot
or ns:myroot
namespaceURI
- URI of root element namespace or null
doctypePublicID
- public ID of DOCTYPE or null
doctypeSystemID
- system ID of DOCTYPE or null
if no DOCTYPE
required and doctypePublicID is also null
public static Document parse(InputSource input, boolean validate, boolean namespaceAware, ErrorHandler errorHandler, EntityResolver entityResolver) throws IOException, SAXException
input
- a parser input (for URL users use: new InputSource(url.toExternalForm())
validate
- if true validating parser is usednamespaceAware
- if true DOM is created by namespace aware parsererrorHandler
- a error handler to notify about exception or null
entityResolver
- - SAX entity resolver (e.g. EntityCatalog.getDefault()
)or null
public static void write(Document doc, OutputStream out, String enc) throws IOException
doc
- DOM Document to be writtenout
- data sinkenc
- - XML defined encoding name (i.e. IANA defined, one of UTF-8, UNICODE, ASCII).public static String toAttributeValue(String val) throws CharConversionException
<
, &
, '
and "
will be escaped.
Note: An XML processor returns normalized value that can be different.val
- a string to be escapedCharConversionException
- if val contains an inproper XML characterpublic static String toElementContent(String val) throws CharConversionException
<
,
&
and > in ]]>
sequences).
- Parameters:
val
- a string to be escaped- Returns:
- escaped value
- Throws:
CharConversionException
- if val contains an inproper XML character- Since:
- 1.40
public static String toHex(byte[] val, int start, int len)
val
- data to be convertedstart
- offsetlen
- countpublic static byte[] fromHex(char[] hex, int start, int len) throws IOException
toHex
.hex
- data to be convertedstart
- offsetlen
- countIOException
- if input does not represent hex encoded value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |