The PDK Java API is part of the Portal Developer Kit on Portal Studio

oracle.portal.utils.xml.v2
Class XMLUtil

java.lang.Object
  |
  +--oracle.portal.utils.xml.v2.XMLUtil

public class XMLUtil
extends java.lang.Object

Class containing utility methods for parsing and manipulating XML documents.


Constructor Summary
XMLUtil()
           
 
Method Summary
static oracle.xml.parser.v2.XMLDocument applyXSL(oracle.xml.parser.v2.XMLDocument xmldoc, oracle.xml.parser.v2.XSLStylesheet xsl, java.io.OutputStream errOut)
          Apply the given stylesheet to the given XML document, reporting errors and warnings to the given OutputStream.
static int compareVersions(java.lang.String version1, java.lang.String version2)
          Compare the given version number strings.
static java.lang.String escapeXML(java.lang.String text, boolean isAttribute)
          General utility to escape text for inclusion in XML.
static java.lang.String escapeXMLAttribute(java.lang.String text)
          Properly escapes text for inclusion in as XML attribute value.
static java.lang.String escapeXMLText(java.lang.String text)
          Properly escapes text for inclusion in as XML text.
static boolean getBooleanValue(java.lang.String value)
          Convert the given String encoding of a boolean value ("true" or "false") to a boolean.
static java.util.Iterator getStyleSheetPIs(oracle.xml.parser.v2.XMLDocument doc)
          Get an Iterator of ProcessingInstructions from the given XML document which have a target of "xml-stylesheet".
static java.util.Iterator getTargetPIs(oracle.xml.parser.v2.XMLDocument doc, java.lang.String targetName)
          Get an Iterator of ProcessingInstructions from the given XML document which have the specified target (for example, "xml-stylesheet").
static int getVersionMajor(java.lang.String version)
          Given a version number string, get the integer corresponding to the 'major version'.
static java.util.Iterator getXslDocs(oracle.xml.parser.v2.XMLDocument doc)
          Get an Iterator of XSLStylesheets referenced by processing instructions in the given XML document which have a target of "xml-stylesheet".
static oracle.xml.parser.v2.XMLDocument parseDocument(java.io.InputStream docInputStream, java.io.OutputStream errOut)
          Parse an XML document from the given InputStream, reporting errors and warnings to the given OutputStream.
static oracle.xml.parser.v2.XMLDocument parseDocument(java.io.Reader docReader, java.io.OutputStream errOut)
          Parse an XML document from the given Reader, reporting errors and warnings to the given OutputStream.
static oracle.xml.parser.v2.XMLDocument parseDocument(java.net.URL docURL, java.io.OutputStream errOut)
          Parse an XML document from the given URL, reporting errors and warnings to the given OutputStream.
static java.util.Map parsePI(org.w3c.dom.ProcessingInstruction pi)
          Given a ProcessingInstruction whose data contains attribute/value pairs, return a Map which contains the attributes as keys and their corresponding values as values.
static oracle.xml.parser.v2.XSLStylesheet parseStylesheet(java.net.URL docURL, java.io.OutputStream errOut)
          Parse an XSL stylesheet from the given URL, reporting errors and warnings to the given OutputStream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtil

public XMLUtil()
Method Detail

parseDocument

public static oracle.xml.parser.v2.XMLDocument parseDocument(java.io.InputStream docInputStream,
                                                             java.io.OutputStream errOut)
                                                      throws java.io.IOException,
                                                             org.xml.sax.SAXException
Parse an XML document from the given InputStream, reporting errors and warnings to the given OutputStream.
Parameters:
docInputStream - InputStream from which the document should be read
errOut - OutputStream to which parsing errors and warnings should be reported
Throws:
java.io.IOException - if an I/O error occurs
org.xml.sax.SAXException - if a parsing error occurs

parseDocument

public static oracle.xml.parser.v2.XMLDocument parseDocument(java.io.Reader docReader,
                                                             java.io.OutputStream errOut)
                                                      throws java.io.IOException,
                                                             org.xml.sax.SAXException
Parse an XML document from the given Reader, reporting errors and warnings to the given OutputStream.
Parameters:
docReader - Reader from which the document should be read
errOut - OutputStream to which parsing errors and warnings should be reported
Throws:
java.io.IOException - if an I/O error occurs
org.xml.sax.SAXException - if a parsing error occurs

parseDocument

public static oracle.xml.parser.v2.XMLDocument parseDocument(java.net.URL docURL,
                                                             java.io.OutputStream errOut)
                                                      throws java.io.IOException,
                                                             org.xml.sax.SAXException
Parse an XML document from the given URL, reporting errors and warnings to the given OutputStream.
Parameters:
docURL - URL from which the document should be read
errOut - OutputStream to which parsing errors and warnings should be reported
Throws:
java.io.IOException - if an I/O error occurs
org.xml.sax.SAXException - if a parsing error occurs

parseStylesheet

public static oracle.xml.parser.v2.XSLStylesheet parseStylesheet(java.net.URL docURL,
                                                                 java.io.OutputStream errOut)
                                                          throws java.io.IOException,
                                                                 org.xml.sax.SAXException,
                                                                 oracle.xml.parser.v2.XSLException
Parse an XSL stylesheet from the given URL, reporting errors and warnings to the given OutputStream.
Parameters:
docURL - URL from which the stylesheet should be read
errOut - OutputStream to which parsing errors and warnings should be reported
Throws:
java.io.IOException - if an I/O error occurs
org.xml.sax.SAXException - if a parsing error occurs
oracle.xml.parser.v2.XSLException - if the document is not a valid stylesheet

applyXSL

public static oracle.xml.parser.v2.XMLDocument applyXSL(oracle.xml.parser.v2.XMLDocument xmldoc,
                                                        oracle.xml.parser.v2.XSLStylesheet xsl,
                                                        java.io.OutputStream errOut)
                                                 throws java.io.IOException,
                                                        oracle.xml.parser.v2.XSLException
Apply the given stylesheet to the given XML document, reporting errors and warnings to the given OutputStream.
Parameters:
xmldoc - a parsed XML document
xsl - a parsed XSL stylesheet
errOut - OutputStream to which stylesheet processing errors should be reported

getTargetPIs

public static java.util.Iterator getTargetPIs(oracle.xml.parser.v2.XMLDocument doc,
                                              java.lang.String targetName)
Get an Iterator of ProcessingInstructions from the given XML document which have the specified target (for example, "xml-stylesheet").
Parameters:
doc - the XML document
targetName - the target of the processing instructions to be returned
Returns:
Iterator of ProcessingInstructions from the given XML document which have the specified target.

getStyleSheetPIs

public static java.util.Iterator getStyleSheetPIs(oracle.xml.parser.v2.XMLDocument doc)
Get an Iterator of ProcessingInstructions from the given XML document which have a target of "xml-stylesheet".
Parameters:
doc - the XML document
Returns:
Iterator of ProcessingInstructions from the given XML document which have a target of "xml-stylesheet".

getXslDocs

public static java.util.Iterator getXslDocs(oracle.xml.parser.v2.XMLDocument doc)
                                     throws java.io.IOException,
                                            org.xml.sax.SAXException,
                                            oracle.xml.parser.v2.XSLException
Get an Iterator of XSLStylesheets referenced by processing instructions in the given XML document which have a target of "xml-stylesheet".
Parameters:
doc - the XML document
Returns:
Iterator of XSLStylesheets referenced by processing instructions in the given XML document which have a target of "xml-stylesheet".

parsePI

public static java.util.Map parsePI(org.w3c.dom.ProcessingInstruction pi)
                             throws org.xml.sax.SAXException
Given a ProcessingInstruction whose data contains attribute/value pairs, return a Map which contains the attributes as keys and their corresponding values as values.
Parameters:
pi - a processing instruction
Returns:
Map mapping processing instruction attributes to values

getBooleanValue

public static boolean getBooleanValue(java.lang.String value)
Convert the given String encoding of a boolean value ("true" or "false") to a boolean.
Parameters:
value - String representation of a boolean value
Returns:
true if the string is not null and matches the string "true" in a case-insensitive comparison

getVersionMajor

public static int getVersionMajor(java.lang.String version)
Given a version number string, get the integer corresponding to the 'major version'. For example, calling this method on the string "3.2.1" would return the integer 3.
Parameters:
version - a version number string, e.g. "3.2.1"
Returns:
the integer 'major version' represented by the digits before the first '.' in the string
Throws:
java.lang.NumberFormatException - if the string does not contain a valid integer major version

compareVersions

public static int compareVersions(java.lang.String version1,
                                  java.lang.String version2)
Compare the given version number strings.
Parameters:
version1 - First version number string to compare. Should consist of decimal characters separated by dots, e.g. "3.2.1".
version2 - Second version number string to compare. Should consist of decimal characters separated by dots, e.g. "3.2.1".
Returns:
An integer indicating whether version1 is greater than, equal to, or less than version2: 1 if version1 is greater, 0 if it is equal to version2, and -1 if version1 is less than version2.

escapeXMLAttribute

public static java.lang.String escapeXMLAttribute(java.lang.String text)
Properly escapes text for inclusion in as XML attribute value. I.e. escapes &, <, >, ', and ".
Parameters:
text - the String to escape
Returns:
the escaped text.

escapeXMLText

public static java.lang.String escapeXMLText(java.lang.String text)
Properly escapes text for inclusion in as XML text. I.e. escapes &, <, and >.
Parameters:
text - the String to escape
Returns:
the escaped text.

escapeXML

public static java.lang.String escapeXML(java.lang.String text,
                                         boolean isAttribute)
General utility to escape text for inclusion in XML. I.e. escapes &, <, and > if regular XML text or escapes &, <, >, ', and " if an XML attribute value.
Parameters:
text - the String to escape
isAttribute - indicates if the text should be escaped for inclusion as an attributes value. If false then regular text is assumed.
Returns:
the escaped text.

The PDK Java API is part of the Portal Developer Kit on Portal Studio

Copyright (c) 2002, Oracle Corporation. All Rights Reserved.