Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

oracle.ide.xml
Class XMLUtil

java.lang.Object
  extended by oracle.ide.xml.XMLUtil

public final class XMLUtil
extends java.lang.Object

Utility methods for quickly inspecting the contents of an XML file.


Method Summary
static java.lang.String getElementValue(java.io.File file, java.lang.String element)
          Returns the value associated with the first occurrence of the specified element tag contained in the xml file pointed to by the file.
static java.lang.String getElementValue(java.net.URL url, java.lang.String element)
          Returns the value associated with the first occurrence of the specified element tag contained in the xml file pointed to by the url.
static StartElementPacket getXMLRootElement(java.io.InputStream in)
           
static StartElementPacket getXMLRootElement(java.io.Reader reader)
           
static StartElementPacket getXMLRootElement(java.net.URL url)
          This method assumes that the content pointed to by the given URL is for an XML file.
static oracle.xml.parser.v2.XSLStylesheet loadXSLT(java.net.URL xslt)
          This method loads an XSLT file into memory, setting the "encoding" attribute on the xsl:output element to match the default IANA encoding of the current platform.
static java.lang.String toNamespaceURI(java.lang.String documentID)
          Returns a full XML Namespace URI that uses the current base namespace URI and appends the specified "document ID".
static java.lang.String toString(oracle.xml.parser.v2.XMLDocument xmlDocument)
          Returns the specified XMLDocument as a single String representing the contents of the document as if they were emitted to a file.
static void transformXML(java.net.URL xml, java.net.URL xslt)
          Transforms an XML document according to an XSLT file.
static void writeXML(oracle.xml.parser.v2.XMLDocument xmlDocument, java.io.OutputStream out)
          Writes the specified XMLDocument to the output stream specified.
static void writeXML(oracle.xml.parser.v2.XMLDocument xmlDocument, java.io.PrintWriter printWriter)
           
static void writeXML(oracle.xml.parser.v2.XMLDocument xmlDocument, java.io.PrintWriter printWriter, int indentIncr)
           
static void writeXML(oracle.xml.parser.v2.XMLDocument xmlDocument, java.io.PrintWriter printWriter, int indentIncr, boolean useTabs, int tabSize)
           
static void writeXML(oracle.xml.parser.v2.XMLDocument xmlDocument, java.net.URL url)
          Writes the specified XMLDocument to the file located at the specified URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getXMLRootElement

public static StartElementPacket getXMLRootElement(java.net.URL url)
                                            throws java.io.FileNotFoundException
This method assumes that the content pointed to by the given URL is for an XML file. The method then reads the XML content and returns the root element name when it is found.

If the XML file could not be parsed for some reason (e.g. there was an XML parsing error), then null is returned.

Throws:
java.io.FileNotFoundException

getXMLRootElement

public static StartElementPacket getXMLRootElement(java.io.InputStream in)

getXMLRootElement

public static StartElementPacket getXMLRootElement(java.io.Reader reader)

loadXSLT

public static oracle.xml.parser.v2.XSLStylesheet loadXSLT(java.net.URL xslt)
                                                   throws java.io.IOException,
                                                          org.xml.sax.SAXException,
                                                          oracle.xml.parser.v2.XSLException
This method loads an XSLT file into memory, setting the "encoding" attribute on the xsl:output element to match the default IANA encoding of the current platform.

Throws:
java.io.IOException
org.xml.sax.SAXException
oracle.xml.parser.v2.XSLException

transformXML

public static void transformXML(java.net.URL xml,
                                java.net.URL xslt)
                         throws java.io.IOException,
                                org.xml.sax.SAXException,
                                oracle.xml.parser.v2.XSLException
Transforms an XML document according to an XSLT file.

Throws:
java.io.IOException
org.xml.sax.SAXException
oracle.xml.parser.v2.XSLException

writeXML

public static void writeXML(oracle.xml.parser.v2.XMLDocument xmlDocument,
                            java.net.URL url)
                     throws java.io.IOException
Writes the specified XMLDocument to the file located at the specified URL.

Throws:
java.io.IOException - if an I/O error occurs when writing the XML file.

writeXML

public static void writeXML(oracle.xml.parser.v2.XMLDocument xmlDocument,
                            java.io.OutputStream out)
                     throws java.io.IOException
Writes the specified XMLDocument to the output stream specified. Upon completion, the output stream will be closed.

Throws:
java.io.IOException - if an I/O error occurs when writing the XML file.

writeXML

public static void writeXML(oracle.xml.parser.v2.XMLDocument xmlDocument,
                            java.io.PrintWriter printWriter)
                     throws java.io.IOException
Throws:
java.io.IOException

writeXML

public static void writeXML(oracle.xml.parser.v2.XMLDocument xmlDocument,
                            java.io.PrintWriter printWriter,
                            int indentIncr)
                     throws java.io.IOException
Throws:
java.io.IOException

writeXML

public static void writeXML(oracle.xml.parser.v2.XMLDocument xmlDocument,
                            java.io.PrintWriter printWriter,
                            int indentIncr,
                            boolean useTabs,
                            int tabSize)
                     throws java.io.IOException
Throws:
java.io.IOException

toNamespaceURI

public static java.lang.String toNamespaceURI(java.lang.String documentID)
Returns a full XML Namespace URI that uses the current base namespace URI and appends the specified "document ID".

For example, passing in "jproject" would return something like:

      http://xmlns.oracle.com/jdeveloper/902rc/jproject
  
Passing in "j2ee/ejb-jar" would return something like:
      http://xmlns.oracle.com/jdeveloper/902rc/j2ee/ejb-jar
  


toString

public static java.lang.String toString(oracle.xml.parser.v2.XMLDocument xmlDocument)
Returns the specified XMLDocument as a single String representing the contents of the document as if they were emitted to a file. If an IOException occurs during processing, the empty string is returned.


getElementValue

public static java.lang.String getElementValue(java.net.URL url,
                                               java.lang.String element)
Returns the value associated with the first occurrence of the specified element tag contained in the xml file pointed to by the url. Returns null if the tag is not found, or does to have a text value associated with it.


getElementValue

public static java.lang.String getElementValue(java.io.File file,
                                               java.lang.String element)
Returns the value associated with the first occurrence of the specified element tag contained in the xml file pointed to by the file. Returns null if the tag is not found, or does to have a text value associated with it.


Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

Copyright © 1997, 2010, Oracle. All rights reserved.