XML parsing default empty namespace

Hi
We have the the following XML document. How can extract the values of
StreetAddress element using extract or extractvalue Sql functions ?
Thanks
Thahseen
<data_StandardAddressResponse xmlns="http://www.IVR_data.com/data/dataAddressValidation"> <data_StandardAddressResult> <xs:schema id="Messages" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Messages" msdata:IsDataSet="true">
<xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="CorrectedAddress"> <xs:complexType> <xs:sequence> <xs:element name="MatchCount" type="xs:string" minOccurs="0"/>
<xs:element name="FirmName" type="xs:string" minOccurs="0"/>
<xs:element name="PRUrb" type="xs:string" minOccurs="0"/>
<xs:element name="StreetAddress" type="xs:string" minOccurs="0"/>
<xs:element name="CityStZip" type="xs:string" minOccurs="0"/>
<xs:element name="Message" type="xs:string" minOccurs="0"/>
<xs:element name="ErrorCode" type="xs:string" minOccurs="0"/>
</xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema> <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<Messages xmlns=""> <CorrectedAddress diffgr:id="CorrectedAddress1" msdata:rowOrder="0" diffgr:hasChanges="inserted">
<MatchCount>1</MatchCount> <FirmName/> <PRUrb/> <StreetAddress>25 MADISON RD</StreetAddress>
<CityStZip>TOTOWA NJ 07512-1003</CityStZip>
<Message>Corrected ZIP code Address Corrected</Message>
<ErrorCode>0</ErrorCode> </CorrectedAddress> </Messages> </diffgr:diffgram> </data_StandardAddressResult> </data_StandardAddressResponse>

Assumning your data is in a table of XMLType called xml_data, the following query will extract the StreetAddress values:
select extractValue(
    object_value,
    '/ns1:data_StandardAddressResponse/ns1:data_StandardAddressResult/ns2:diffgram/Messages/CorrectedAddress/StreetAddress',
    'xmlns:ns1="http://www.IVR_data.com/data/dataAddressValidation" xmlns:ns2="urn:schemas-microsoft-com:xml-diffgram-v1"')
from xml_dataSo there is no namespace mapping required for the elements with no namespace.

Similar Messages

  • XML Parsing error in PL/SQL

    Hello,
    I have some problem in parsing Mircrosoft OpenXML file using Oracle 10g Release2 XML Parser for PL/SQL.
    I use dbms_xmlparser, dbms_xmldom, dbms_xslprocessor packages
    OpenXML file use "w:" as namespace, so every element has prefix "w:" like
    <w:wordDocument ..>
    <w:body..>
    <w:p..>
    <w:r..>
    <w:t..>
    My job is to read OpenXML file inside PL/SQL code, parse it, and load it into the corresponding table.
    Here is my PL/SQL code.
    DECLARE
    doc dbms_xmldom.DOMDocument;
    node_list dbms_xmldom.DOMNodeList;
    l_node dbms_xmldom.DOMNode;
    one_element dbms_xmldom.DOMElement;
    PROCEDURE p (msg VARCHAR2, nl BOOLEAN := TRUE) IS
    BEGIN
    dbms_output.put_line (msg);
    IF nl THEN dbms_output.put(CHR(10)); END IF;
    END:
    BEGIN
    doc := xml.parse(BFileName('XML_DIR','OpenXMLFile.xml'));
    node_list := xpath.selectNodes(doc, '/w:wordDocument/w:body/w:p/w:r/w:t');
    FOR j IN 0..dbms_xmldom.getLength(node_list)-1
    LOOP
    p( xpath.valueOf(dbms_xmldom.item(node_list, j), '.'), nl=>FALSE );
    END LOOP;
    Here is the error message.
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00601: Invalid token in: '/w:wordDocument/w:body/w:p/w:r/w:t
    [starts-with(., "!")]'
    ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 900
    ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 928
    ORA-06512: at "SYSTEM.XPATH", line 173
    ORA-06512: at "SYSTEM.XPATH", line 179
    ORA-06512: at line 38
    I really don't know why I got this error message nor how to solve it. If I remove "w:" manually within open xml file, then parsing works well. I guess XML parser for PL/SQL doesn't recognize ":" or maybe doesn't support namespace?
    My question is
    1. In oracle 10g release2, XML Parser for PL/SQL can recognize ":" in the element name? or does it support namespace? If not, is there any workaround for solving this problem?
    2. How can I make XML Parser recognize ":" in the element name in the xml file or How can I declare namespace in the PL/SQL code so that PL/SQL xml parser can recognize namespace like "w:"?
    In fact, I don't use XML DB and what I want to do is just to load XML file into the relational table and some parts of whole XML file will be inserted into the CLOB in the table.
    Should I really use XML DB to do the above job?
    Any comment or suggestions will be greatly appreciated.

    This works correctly. I added prefixes to your extract path. (I had to add the xmlns:xsi to your root node also.)
    declare
      -- Local variables here
       doc_in       dbms_xmldom.DOMDocument;
       aNodeList    dbms_xmldom.DOMNodeList;
    begin
      -- Test statements here
      doc_in := dbms_xmldom.newdomdocument(
    '<?xml version="1.0" encoding="UTF-8"?>' ||
    '<ap:Collection xmlns:ap="http://www.abc.com/ap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.abc.com/ap template.xsd"> ' ||
    '<ap:info>' ||
    '<ap:data name="Barbie" age="3">' ||
    '</ap:data>' ||
    '</ap:info>' ||
    '</ap:Collection>');
      aNodeList := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(doc_in),
                                                 '/ap:Collection/ap:info',
                                                 'xmlns:ap="http://www.abc.com/ap"');  
      dbms_output.put_line('length of aNodeList = '|| dbms_xmldom.getLength(aNodeList) );
    end;

  • XML parser exception: No documentation !

    Hi,
    I'm getting an exception when looking for
    an <xsl:apply-templates> tag in an XSL file
    thats loaded via the DOMParser.
    Do I need to do anything special to declare
    the XSL Namespace?
    Also, the Parser API docs don't seem to have
    this Exception listed!!!
    Does anyone know more regarding this?
    TIA,
    Vijay
    oracle.xml.parser.v2.XPathException: Namespace prefix 'xsl' used but not declared.
    at oracle.xml.parser.v2.XSLParseString.nextToken(XSLParseString.java:406)
    at oracle.xml.parser.v2.PathExpr.<init>(XSLNodeSetExpr.java:313)
    at oracle.xml.parser.v2.XSLNodeSetExpr.parse(XSLNodeSetExpr.java:147)
    at oracle.xml.parser.v2.XSLNodeSetExpr.parse(XSLNodeSetExpr.java:131)
    at oracle.xml.parser.v2.XSLNodeSetExpr.parse(XSLNodeSetExpr.java:124)
    at oracle.xml.parser.v2.UnaryExpr.parse(XSLExpr.java:357)
    at oracle.xml.parser.v2.MultiplicativeExpr.parse(XSLExpr.java:295)
    at oracle.xml.parser.v2.AdditiveExpr.parse(XSLExpr.java:243)
    at oracle.xml.parser.v2.RelExpr.parse(XSLExpr.java:210)
    at oracle.xml.parser.v2.EqualExpr.parse(XSLExpr.java:160)
    at oracle.xml.parser.v2.AndExpr.parse(XSLExpr.java:110)
    at oracle.xml.parser.v2.XSLExpr.parse(XSLExpr.java:59)
    at oracle.xml.parser.v2.FilterExpr.getPrimaryExpr(XSLNodeSetExpr.java:1444)
    at oracle.xml.parser.v2.FilterExpr.<init>(XSLNodeSetExpr.java:1128)
    at oracle.xml.parser.v2.PathExpr.<init>(XSLNodeSetExpr.java:275)
    at oracle.xml.parser.v2.XSLNodeSetExpr.parse(XSLNodeSetExpr.java:147)
    at oracle.xml.parser.v2.XSLNodeSetExpr.parse(XSLNodeSetExpr.java:131)
    at oracle.xml.parser.v2.XSLExprBase.createNodeSetExpr(XSLExprBase.java:123)
    at oracle.xml.parser.v2.XMLNode.selectNodes(XMLNode.java:763)
    at oracle.xml.parser.v2.XMLNode.selectSingleNode(XMLNode.java:861)
    at com.citicorp.gra.portlets.fxrates.FxRatesPortletContentProvider.createStylesheet(FxRatesPortletContentProvider.java:302)
    at com.citicorp.gra.portlets.fxrates.FxRatesPortletContentProvider.getStylesheet(FxRatesPortletContentProvider.java:341)
    at com.citicorp.gra.portlets.fxrates.FxRatesPortletContentProvider.getContent(FxRatesPortletContentProvider.java:125)
    at portlet.BasePortlet.doPost(BasePortlet.java:100)
    at portlet.BasePortlet.doGet(BasePortlet.java:137)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
    at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:925)
    at allaire.jrun.servlet.JRunNamedDispatcher.include(JRunNamedDispatcher.java:42)
    at allaire.taglib.ServletTag.doEndTag(ServletTag.java:84)
    at jrun__html__fxrates__tagtest2ejsp19._jspService(jrun__html__fxrates__tagtest2ejsp19.java:53)
    at allaire.jrun.jsp.HttpJSPServlet.service(HttpJSPServlet.java:40)
    at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
    at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:925)
    at allaire.jrun.servlet.JRunNamedDispatcher.forward(JRunNamedDispatcher.java:34)
    at allaire.jrun.jsp.JSPServlet.service(JSPServlet.java:175)
    at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
    at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:925)
    at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java:88)
    at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1131)
    at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:330)
    at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java:367)
    at allaire.jrun.ThreadPool.run(ThreadPool.java:272)
    at allaire.jrun.WorkerThread.run(WorkerThread.java:75)
    null

    Hi
    below is the statement which is looking
    for the "xsl:app-templates" element under
    node1, it need an instance of NSResolver.
    XMLElement node1Child2 = (XMLElement) node1.selectSingleNode ("//xsl:apply-templates", resolver );
    // Name Space Resolver
    private class MyNSResolver implements NSResolver {
    * returns the Namespace definition int scope for a given namespace prefix
    public String resolveNamespacePrefix( String prefix ) {
    if ( prefix.equals("xsl")) {
    return "http://www.w3.org/1999/XSL/Transform";
    } else return null;
    } // private class MyNSResolver
    null

  • Weblogic 6.1 and xml parser empty elements

    FYI, It looks like Weblogic changed there xml parser in the transition from
    6.0sp2 to 6.1. Example : The empty Extra Info Class produced and error,
    because it is empty. Where in 6.0sp2 it did not produce and error:
    <taglib>
    <tag>
    <name>indexProperty</name>
    <info>
    some info..
    </info>
    <tagclass>com.pssg.jsp.tags.IndexPropertyTag</tagclass>
    <teiclass></teiclass>
    </tag>
    </taglib>
    ####<Aug 20, 2001 12:20:52 PM PDT> <Info> <HTTP> <devlwebejb1> <camserver>
    <ExecuteThread: '14' for queue: 'default'> <> <> <101047>
    <[WebAppServletContext(7008653,cam,/cam)] resolved taglib uri '/pssglibtags'
    to taglib-location /WEB-INF/tlds/pssgtaglib.tld:>
    ####<Aug 20, 2001 12:20:53 PM PDT> <Info> <HTTP> <devlwebejb1> <camserver>
    <ExecuteThread: '14' for queue: 'default'> <> <> <101160> <Deployment
    descriptor is malformed, check against the DTD:
    org.xml.sax.SAXParseException: The content of element type "tag" must match
    "(name,tagclass,teiclass?,bodycontent?,info?,attribute*)"..>
    ####<Aug 20, 2001 12:20:53 PM PDT> <Error> <HTTP> <devlwebejb1> <camserver>
    <ExecuteThread: '14' for queue: 'default'> <> <> <101020>
    <[WebAppServletContext(7008653,cam,/cam)] Servlet failed with Exception>
    weblogic.servlet.jsp.JspException: (line 1): Error in using tag library
    uri='/pssglibtags' prefix='pssglibtag': For tag 'indexProperty', cannot load
    extra info class ''
    at
    weblogic.servlet.jsp.StandardTagLib.tld_jspException(StandardTagLib.java:901
    -Scot

    hi,
    there are two versions of ldap supported in wls6.1 , ldapv1 and ldavp2
    ldap v1 only has the functionality of listing groups.
    but where ldapv2 doesn't have that functionality,
    by looking at your config , it seems you are using ldap v2..
    if u need that functionality u can use ldapv1.
    thanks
    kiran
    "Bert Cliche" <[email protected]> wrote in message
    news:[email protected]..
    Per a proof of concept, I am having trouble getting WL6.1 to see
    group members as defined in iPlanet LDAP. I can see the groups,
    but modifies to create groups only create them in the local DB.
    Created users also only get placed in the local DB. I can bind
    for searches as Directory Manager via ldapsearch and run queries,
    and the DS gateway works fine. I can dump the LDIF file and the
    entries look fine.
    I copied and modified the template for the Netscape server and
    have the realm setup per the GUI.
    For sanity, everything is very generic as:
    the Root DN is "o=test.org"
    and my "Configuration" part from the config.xml looks like:
    server.authprotocol=simple;
    server.host=localhost;
    membership.filter=(&(uniquemember=%M)(objectclass=groupofuniquenames));
    server.port=390;
    group.dn=o=test.org;
    group.filter=(&(cn=%g)(objectclass=groupofuniquenames));
    server.principal=cn=Directory Manager;
    user.dn=o=test.org;
    server.groupiscontext=false;
    user.filter=(&(uid=%u))
    I added the "authprotocol" as a guess. Note that the server is
    running on port 390, this is not a typo.
    Any ideas what is going wrong?

  • JRE 1.4.2: how to override the default xml parser?

    Hi all,
    I have JRE 1.4.2_03 and I need to replace the default xml "crimson" parser with xerces because the former one doesn't properly handle utf-8 BOM.
    Does anyone have an idea where I should look at for this kind of configuration?
    I skimmed thorugh the oracle docs but couldn't find anything.
    I found a link describing how to change the xml parser in OC4J, but my understanding is that this has little to do with what I am looking for.
    I need to force Saxon 8.6.1, that is invoked by means of java.exe from the command line, to pick up the right xml parser.
    Has anyone else tried this out already?
    Alternatively, is it safe to install JRE 1.5 in place of JRE 1.4.2 on a Oracle 10.1.0.4 database?
    I am told that JRE 1.5 uses a different xml parser that should fix my problem.
    Bye,
    Flavio

    I sorted this out myself.
    Downloaded the latest stable xerces binary (2.5.0) from http://xml.apache.org/dist/xerces-j/
    Then I extracted xercesImpl.jar and put it under:
    %ORACLE_HOME%\LIB\endorsed
    I had to create the endorsed folder as it didn't exist.
    Then, when invoking Saxon using java.exe, I added the following switch:
    -Djava.endorsed.dirs=%ORACLE_HOME%\LIB\endorsed
    That's it.
    You can find some background info on:
    https://jaxp.dev.java.net/Updating.html
    Bye,
    Flavio

  • XML Parsing with namespace

    Hi All,
    I have a requirement to convert XML to itab to be processed further.
    I couldn't parse the XML which contains ns0 (namespace?) as following:
    <ns0:OrderNo>887140</ns0:OrderNo>
    <ns0:CPROD>BD</ns0:CPROD>
    <ns0:CURR>USD</ns0:CURR>
    I'm able to parse If I remove the namespace ns0 from the file as following:
    <OrderNo>887140</OrderNo>
    <CPROD>BD</CPROD>
    <CURR>USD</CURR>
    The thing is the XML file will always come with the namespace ns0.
    I'm using IF_IXML, IF_IXML_STREAM_FACTORY, IF_IXML_ISTREAM, IF_IXML_PARSER, IF_IXML_DOCUMENT to parse the XML.
    Any idea on how to overcome this?
    Thanks,
    Victor.

    Hello Victor,
    fine. I am glad, I could help you.
    Just one note to XSLT Transformations: When using them, you got even the ability to map directly to internal abap tables:
    CALL TRANSFORMATION ZXSLT_YOUR_TRANSFORMATION
      SOURCE XML l_xmlstring
      RESULT DATA = lt_data.
    You just need to transform you xml to the asx:abap name space and that's it
    Look at Re: Help needed XML to Internal table and vice versa, where I show a simple example, how this works.
    Kind regards,
    Hendrik

  • Looking for the java default XML parser?

    Hey guys,
    I just wondering alot about the sometimes mentioned Java Default XML Parser. So I used xerces and it worked fine, but my program doesnt need the whole functionality of xerces and I want to save some space for the resulting project jar. The xerces parser is 1.1 MB huge and instead of xerces I could use the default SAX parser in the java API, I thought.
    Although it is mentioned in some books/documents I can not find it.
    Could you give me an exmaple with the XMLReaderFactory how to use the default parser?
    I would appreciate this alot!
    Thanks.

    Hey,
    yes that I tried before, because I read this too.. If I am doing this Im getting the error:
    Exception in thread "main" org.xml.sax.SAXException: System property org.xml.sax.driver not specified
         at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:90)
         at cfm.com.gui.GUIBuilder.buildGUIPage(GUIBuilder.java:51)
    ...So, this means that the JDK comes not with an default parser implementation I suggest.
    Hmm... stupid! I think I have to ship the xerces parser with my application... but its huge!
    Does anybody know what of the compelling parser are the lighweightest?
    Im gonna look for this answer too....
    Thanks.

  • ANN: XML Parser for Java v2.0.2.6

    The v2.0.2.6 of the XML Parser for Java is now available for download. The following features and bug fixes are included:
    Changes:
    Conformance to the XSLT/XPATH October REC.
    New API in XSLStylesheet class:
    removeParam(String param)
    resetParams()
    Bug fixes:
    Bug #1111423: OutOfMemory exception, if multiple calls made to document()
    Bug #1101028: Unexpected character error in DTD parsing document using Docbook DTD
    Bug #1101021: #default not supported in exclude-result-prefixes
    Bug #1099830: Extra characters inserted into output using the XML Parser
    Bug #1099663: HTML output does not allow only doctype-public to be specified
    Bug #1099536: HTML output does not disable escaping for script, style unless lowercase
    Bug #1098738: ArrayOutOfBoundsException xsl:if test="not(@a)'"
    Bug #1095047: XSLProcessor NPE'S on named templates with non-empty namespaces
    Bug #1094971: XSLStylesheet needs methods for removing parameters
    Bug #1092351: Using valueof() shuffles order of elements in my source document
    Bug #1086663: xsl:sort data-type attribute can now be a namespace-prefixed name
    Bug #1086661: xsl:version attribute now required on literal result element
    Bug #1064692: Default xml-serialization should use empty-element syntax
    Bug #1064689: Current() function doesn't work correctly
    This is the sixth production patch release for v2.
    Oracle XML Team http://technet.oracle.com
    Oracle Technology Network
    null

    The link has been fixed. You will go to the v2 download page
    now. Sorry for the inconvience.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Renilton Oliveira (guest) wrote:
    : I didn't find the file for version 2.0.0.0 as well.
    : Renilton
    : Andrei Filimonov (guest) wrote:
    : : I tried to download XML Parser for Java v2 it seems that
    only
    : v
    : : 1.0.1.4 is available. Could you please give an exact URL for
    : v2
    : : download?
    : : Andrei Filimonov
    : : Oracle XML Team wrote:
    : : : The Oracle XML v2 parser is now available for download
    here
    : as
    : : : an early beta release and is written in Java. It features
    : an
    : : : improved architecture over the Oracle XML v1 parser and
    has
    : : : shown better performance on small to large XML documents.
    : It
    : : : will also be able to format the XML document according to
    a
    : : : stylesheet, having integrated an XSLT processor.
    : : : Version 2 of the XML Parser for Java, besides
    incorporating
    : an
    : : : XSLT processor, has been re-architected from version 1.
    This
    : : has
    : : : resulted in a number of changes to the class names
    : especially
    : : : those that support Namespaces. See v2changes.txt and
    : the .diff
    : : : difference files in the sample directory.
    : : : Oracle XML Team
    : : : http://technet.oracle.com
    : : : Oracle Technology Network
    null

  • Xml parsing error while selecting whole result set for sql query

    Hi All,
    I am having xml parsing error while selecting whole query result set. The data is coming fine for default result set of 50 rows.
    My exception is below.
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00234: namespace prefix "xsi" is not declared
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 254
    ORA-06512: at line 1
    *31011. 00000 - "XML parsing failed"*
    **Cause: XML parser returned an error while trying to parse the document.*
    **Action: Check if the document to be parsed is valid.*
    My sql query is below that is giving results for default result set of 50 rows.
    select extract(xmlType(clob_xml_colm_name), '//v2:node1//childnode/text()','xmlns:v2="namespace_url"').getStringVal()  from table_name
    My sql developer version is below.
    Java(TM) Platform     1.7.0_04
    Oracle IDE     3.1.07.42
    Versioning Support     3.1.07.42
    My database version is below.
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit
    Please could any one help me urgently as the sql query is supposed to be correct as it is returning query results, but the problem happening when i try to select whole result set.
    Thanks and regards,

    What does the XML look like? It appears that some of the supposed XML stored as a CLOB is not really valid XML. Find the row in the table that is causing your issue and review the "XML" in it.

  • Bpel-108-UsingXQuery $publisher - oracle.xml.parser.v2.XMLElement@8b8e58

    Hello,
    I am using Oracle SOA Suite 11.1.1.4.0 While executing the XQuery example bpel-108-UsingXQuery I am facing the following problem/error.
    The Xquery in the example is:
    xquery version "1.0";
    declare namespace ns0 = "http://example.com/bpel/books";
    declare namespace ns1 = "http://samples.otn.com/xquerysample";
    declare variable $category as node() external;
    declare variable $publisher as xs:string external;
    <bookReport>
    for $b in //ns0:BOOKS/ns0:ITEM
    where data($b/ns0:PUBLISHER) = $publisher
    order by string-length($b/TITLE) return
    <book>
    <author> { data($b/ns0:AUTHOR) } </author>
    <title> { data($b/ns0:TITLE) } </title>
    <price>{ data(doc("pricelist.xml")/ns1:pricelist/ns1:product[1]/ns1:price) }</price>
    <publisher>{ $publisher }</publisher>
    { $category }
    </book>
    </bookReport>
    The variable $publisher, declared in 'declare variable $publisher as xs:string external' shall have the value 'Associated Press' as this has been assigned in the BPEL but it has in fact the value 'oracle.xml.parser.v2.XMLElement@8b8e58'.
    The variable $category has the correct value.
    What is here wrong or is it a bug in 11.1.1.4.0 in the oracle.xml.parser.v2.XMLElement class.

    What a mess:
    org.w3c.Element element = (org.w3c.Element) payload.get("payload");
    private Document writeOraXMLtoDocument(org.w3c.Element payload) throws ParserConfigurationException, SAXException, IOException, TransformerException{
              ByteArrayInputStream inputStream = new ByteArrayInputStream(writeXMLToStream(new DOMSource(payload)).toByteArray());
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              DocumentBuilder builder =factory.newDocumentBuilder();
              return builder.parse(inputStream);
         private ByteArrayOutputStream writeXMLToStream(Source source) throws TransformerException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    // Prepare the output file
    Result result = new StreamResult(out);
    // Write the DOM document to the file
    TransformerFactory x = TransformerFactory.newInstance();
    Transformer xformer = x.newTransformer();
    xformer.transform(source, result);
    return out;
    Note, that you have to use the oracle transformer located in the xmlparserv2.jar
    if it is not your default transformer , you have to set it at least for the above code by System.setProperty("javax.xml.transform.TransformerFactory","..classname...");

  • Error in parsing: SAX2 driver class com.sun.xml.parser not found

    Hi I have this exception
    Error in parsing: SAX2 driver class com.sun.xml.parser not found
    when I try to run the examples from the book xml and java
    I have added the following jar files to the class path that i have download form java.sun.com
    xml.jar
    xalan.jar
    jaxp.jar
    crimson.jar
    Please can anyone tell me what is missing or wrong..the code must be right since written by oreilly... please have u any ideA
    XMLReaderFactory.createXMLReader(
    // "org.apache.xerces.parsers.SAXParser");
                        "com.sun.xml.parser");//
    I HAVE ONLY CHANGED THIS LINE FROM THE apache parser..to com.sun.xml.parser
    THIS IS THE ALL CODE
    import java.io.IOException;
    import org.xml.sax.Attributes;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.ErrorHandler;
    import org.xml.sax.Locator;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.XMLReader;
    import org.xml.sax.helpers.XMLReaderFactory;
    import org.xml.sax.*;
    * <b><code>SAXParserDemo</code></b> will take an XML file and parse it using SAX,
    * displaying the callbacks in the parsing lifecycle.
    * @author Brett McLaughlin
    * @version 1.0
    public class SAXParserDemo {
    * <p>
    * This parses the file, using registered SAX handlers, and output
    * the events in the parsing process cycle.
    * </p>
    * @param uri <code>String</code> URI of file to parse.
    public void performDemo(String uri) {
    System.out.println("Parsing XML File: " + uri + "\n\n");
    // Get instances of our handlers
    ContentHandler contentHandler = new MyContentHandler();
    ErrorHandler errorHandler = new MyErrorHandler();
    try {
    // Instantiate a parser
    XMLReader parser =
    XMLReaderFactory.createXMLReader(
    // "org.apache.xerces.parsers.SAXParser");
                        "com.sun.xml.parser");// I HAVE ONLY CHANGED THIS LINE FROM THE apache parser..
    // Register the content handler
    parser.setContentHandler(contentHandler);
    // Register the error handler
    parser.setErrorHandler(errorHandler);
    // Parse the document
    parser.parse(uri);
    } catch (IOException e) {
    System.out.println("Error reading URI: " + e.getMessage());
    } catch (SAXException e) {
    System.out.println("Error in parsing: " + e.getMessage());
    * <p>
    * This provides a command line entry point for this demo.
    * </p>
    public static void main(String[] args) {
    // if (args.length != 1) {
    // System.out.println("Usage: java SAXParserDemo [XML URI]");
    // System.exit(0);
    //String uri = args[0];
    SAXParserDemo parserDemo = new SAXParserDemo();
    parserDemo.performDemo("content.xml");
    * <b><code>MyContentHandler</code></b> implements the SAX
    * <code>ContentHandler</code> interface and defines callback
    * behavior for the SAX callbacks associated with an XML
    * document's content.
    class MyContentHandler implements ContentHandler {
    /** Hold onto the locator for location information */
    private Locator locator;
    * <p>
    * Provide reference to <code>Locator</code> which provides
    * information about where in a document callbacks occur.
    * </p>
    * @param locator <code>Locator</code> object tied to callback
    * process
    public void setDocumentLocator(Locator locator) {
    System.out.println(" * setDocumentLocator() called");
    // We save this for later use if desired.
    this.locator = locator;
    * <p>
    * This indicates the start of a Document parse - this precedes
    * all callbacks in all SAX Handlers with the sole exception
    * of <code>{@link #setDocumentLocator}</code>.
    * </p>
    * @throws <code>SAXException</code> when things go wrong
    public void startDocument() throws SAXException {
    System.out.println("Parsing begins...");
    * <p>
    * This indicates the end of a Document parse - this occurs after
    * all callbacks in all SAX Handlers.</code>.
    * </p>
    * @throws <code>SAXException</code> when things go wrong
    public void endDocument() throws SAXException {
    System.out.println("...Parsing ends.");
    * <p>
    * This will indicate that a processing instruction (other than
    * the XML declaration) has been encountered.
    * </p>
    * @param target <code>String</code> target of PI
    * @param data <code>String</code containing all data sent to the PI.
    * This typically looks like one or more attribute value
    * pairs.
    * @throws <code>SAXException</code> when things go wrong
    public void processingInstruction(String target, String data)
    throws SAXException {
    System.out.println("PI: Target:" + target + " and Data:" + data);
    * <p>
    * This will indicate the beginning of an XML Namespace prefix
    * mapping. Although this typically occur within the root element
    * of an XML document, it can occur at any point within the
    * document. Note that a prefix mapping on an element triggers
    * this callback <i>before</i> the callback for the actual element
    * itself (<code>{@link #startElement}</code>) occurs.
    * </p>
    * @param prefix <code>String</code> prefix used for the namespace
    * being reported
    * @param uri <code>String</code> URI for the namespace
    * being reported
    * @throws <code>SAXException</code> when things go wrong
    public void startPrefixMapping(String prefix, String uri) {
    System.out.println("Mapping starts for prefix " + prefix +
    " mapped to URI " + uri);
    * <p>
    * This indicates the end of a prefix mapping, when the namespace
    * reported in a <code>{@link #startPrefixMapping}</code> callback
    * is no longer available.
    * </p>
    * @param prefix <code>String</code> of namespace being reported
    * @throws <code>SAXException</code> when things go wrong
    public void endPrefixMapping(String prefix) {
    System.out.println("Mapping ends for prefix " + prefix);
    * <p>
    * This reports the occurrence of an actual element. It will include
    * the element's attributes, with the exception of XML vocabulary
    * specific attributes, such as
    * <code>xmlns:[namespace prefix]</code> and
    * <code>xsi:schemaLocation</code>.
    * </p>
    * @param namespaceURI <code>String</code> namespace URI this element
    * is associated with, or an empty
    * <code>String</code>
    * @param localName <code>String</code> name of element (with no
    * namespace prefix, if one is present)
    * @param rawName <code>String</code> XML 1.0 version of element name:
    * [namespace prefix]:[localName]
    * @param atts <code>Attributes</code> list for this element
    * @throws <code>SAXException</code> when things go wrong
    public void startElement(String namespaceURI, String localName,
    String rawName, Attributes atts)
    throws SAXException {
    System.out.print("startElement: " + localName);
    if (!namespaceURI.equals("")) {
    System.out.println(" in namespace " + namespaceURI +
    " (" + rawName + ")");
    } else {
    System.out.println(" has no associated namespace");
    for (int i=0; i<atts.getLength(); i++)
    System.out.println(" Attribute: " + atts.getLocalName(i) +
    "=" + atts.getValue(i));
    * <p>
    * Indicates the end of an element
    * (<code></[element name]></code>) is reached. Note that
    * the parser does not distinguish between empty
    * elements and non-empty elements, so this will occur uniformly.
    * </p>
    * @param namespaceURI <code>String</code> URI of namespace this
    * element is associated with
    * @param localName <code>String</code> name of element without prefix
    * @param rawName <code>String</code> name of element in XML 1.0 form
    * @throws <code>SAXException</code> when things go wrong
    public void endElement(String namespaceURI, String localName,
    String rawName)
    throws SAXException {
    System.out.println("endElement: " + localName + "\n");
    * <p>
    * This will report character data (within an element).
    * </p>
    * @param ch <code>char[]</code> character array with character data
    * @param start <code>int</code> index in array where data starts.
    * @param end <code>int</code> index in array where data ends.
    * @throws <code>SAXException</code> when things go wrong
    public void characters(char[] ch, int start, int end)
    throws SAXException {
    String s = new String(ch, start, end);
    System.out.println("characters: " + s);
    * <p>
    * This will report whitespace that can be ignored in the
    * originating document. This is typically only invoked when
    * validation is ocurring in the parsing process.
    * </p>
    * @param ch <code>char[]</code> character array with character data
    * @param start <code>int</code> index in array where data starts.
    * @param end <code>int</code> index in array where data ends.
    * @throws <code>SAXException</code> when things go wrong
    public void ignorableWhitespace(char[] ch, int start, int end)
    throws SAXException {
    String s = new String(ch, start, end);
    System.out.println("ignorableWhitespace: [" + s + "]");
    * <p>
    * This will report an entity that is skipped by the parser. This
    * should only occur for non-validating parsers, and then is still
    * implementation-dependent behavior.
    * </p>
    * @param name <code>String</code> name of entity being skipped
    * @throws <code>SAXException</code> when things go wrong
    public void skippedEntity(String name) throws SAXException {
    System.out.println("Skipping entity " + name);
    * <b><code>MyErrorHandler</code></b> implements the SAX
    * <code>ErrorHandler</code> interface and defines callback
    * behavior for the SAX callbacks associated with an XML
    * document's errors.
    class MyErrorHandler implements ErrorHandler {
    * <p>
    * This will report a warning that has occurred; this indicates
    * that while no XML rules were "broken", something appears
    * to be incorrect or missing.
    * </p>
    * @param exception <code>SAXParseException</code> that occurred.
    * @throws <code>SAXException</code> when things go wrong
    public void warning(SAXParseException exception)
    throws SAXException {
    System.out.println("**Parsing Warning**\n" +
    " Line: " +
    exception.getLineNumber() + "\n" +
    " URI: " +
    exception.getSystemId() + "\n" +
    " Message: " +
    exception.getMessage());
    throw new SAXException("Warning encountered");
    * <p>
    * This will report an error that has occurred; this indicates
    * that a rule was broken, typically in validation, but that
    * parsing can reasonably continue.
    * </p>
    * @param exception <code>SAXParseException</code> that occurred.
    * @throws <code>SAXException</code> when things go wrong
    public void error(SAXParseException exception)
    throws SAXException {
    System.out.println("**Parsing Error**\n" +
    " Line: " +
    exception.getLineNumber() + "\n" +
    " URI: " +
    exception.getSystemId() + "\n" +
    " Message: " +
    exception.getMessage());
    throw new SAXException("Error encountered");
    * <p>
    * This will report a fatal error that has occurred; this indicates
    * that a rule has been broken that makes continued parsing either
    * impossible or an almost certain waste of time.
    * </p>
    * @param exception <code>SAXParseException</code> that occurred.
    * @throws <code>SAXException</code> when things go wrong
    public void fatalError(SAXParseException exception)
    throws SAXException {
    System.out.println("**Parsing Fatal Error**\n" +
    " Line: " +
    exception.getLineNumber() + "\n" +
    " URI: " +
    exception.getSystemId() + "\n" +
    " Message: " +
    exception.getMessage());
    throw new SAXException("Fatal Error encountered");

    I have seen this error when I'm executing inside one of the (j2ee sun reference implementation) server containers (either web or ejb). I believe its caused by "something" having previously loaded the "sax 1 driver class". In my case, I think the container or server is loading the sax parser from a jar that contains a sax 1 version. If you can, ensure that nothing is loading the sax 1 parser from another jar on your system. Verify that you are loading the sax parser from a jar containing the latest version so that you get the sax 2 compliant parser. Good luck!

  • XML Parsing Error when opening Dreamweaver CS4

    Hi guys, I downloaded a trial version of Dreamweaver CS4
    which was downloaded from the adobe website and once i try
    installing it it comes up with 'please delete current menus.xml
    file and then rename menus.bak file to menus.xml'. Once I tried
    that the new renamed xml file has the same problem as the old one.
    Now, When i opened up the file in Firefox it came up with an XML
    Parsing error. The exact error is as below:
    XML Parsing Error: prefix not bound to a namespace
    Location:
    file:///C:/Program%20Files/Adobe/Adobe%20Dreamweaver%20CS4/configuration/Menus/menus.xml
    Line Number 12, Column 5: <shortcut
    mmstring:name="menus/DWShortcuts_Main_Quit" key="Opt+F4"
    command="dw.quitApplication()" id="DWShortcuts_Main_Quit" />
    ----^
    I am running windows XP SP3. Can anyone offer an
    insight/possible solution? I've already tried the following methods
    which have been suggested by other forums:
    CS4 clean script on Adobe website
    Microsoft installer clean up
    uninstall and reinstall all CS4/adobe products
    deleting Cache.db
    deleting Macromedia folder
    deleting faulty line in menus.xml file
    Is there anything else I can do? Thanks guys!

    1) Close Dreamweaver
    2) Navigate to the Design.xml file and rename it.
    3) Launch Dreamweaver and it will recreate the Design.xml file
    The AppData folder is hidden by default on Windows, so you need to enable the option to view hidden files and folders in order to locate it, as follows:
    In Vista/Windows 7, select Start > Computer > Organize > Folder and Search Options > View. In Advanced settings, choose Show hidden files and folders. 
    In Windows XP, select Start > My Computer > Tools > Folder Options > View. In Advanced settings, choose Show hidden files and folders.
    Once you turn on this option, hidden folders are displayed as dimmed icons to remind you to treat them with care.

  • ANN: XML Parser for Java v2.0.2.5

    The v2.0.2.5 of the XML Parser for Java is now available for
    download. The following features and bug fixes are included:
    Conformance to the XSLT/XPATH October PR.
    Support for internationalized error messages has been added. The
    locale can be set using setLocale(java.util.Locale) function in
    XSLProcessor, SAXParser, and DOMParser.
    New APIs in XMLNode class:
    value-of(String pattern)
    selectNodes(String pattern)
    selectSingleNode(String pattern)
    selectSingleNode(String pattern, NSResolver ns)
    New API in XSLStylesheet class
    setParam(String param, String value)
    Bug fixes:
    Bug #957465: Missing a way to set stylesheet-level param-
    variables
    Bug #962290: selectNodes() improvements
    Bug #1033472: Html output prints empty elements for non-empty
    elements
    Bug #1040717: Character entity for greater that in html output
    style
    Bug #1046003: Bug is parsing text nodes larger than 16K
    Bug #1051671: 'xsl:namespace-alias' not supported
    Bug #1052387: Disable-output-escaping doesn't flush while
    printing
    Bug #1053273: 'xsl:message' terminate attribute not supported
    Bug #1058004: No access to media-type and encoding on xsl:output
    Bug #1058008: xsl:version attribute not copied to result
    Bug #1061159: Exclude-result-prefixes not supported
    Bug #1067965: Bug in Non-validating parser while reading QNames
    in DTD
    This is the fifth production patch release for v2.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

    The link has been fixed. You will go to the v2 download page
    now. Sorry for the inconvience.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Renilton Oliveira (guest) wrote:
    : I didn't find the file for version 2.0.0.0 as well.
    : Renilton
    : Andrei Filimonov (guest) wrote:
    : : I tried to download XML Parser for Java v2 it seems that
    only
    : v
    : : 1.0.1.4 is available. Could you please give an exact URL for
    : v2
    : : download?
    : : Andrei Filimonov
    : : Oracle XML Team wrote:
    : : : The Oracle XML v2 parser is now available for download
    here
    : as
    : : : an early beta release and is written in Java. It features
    : an
    : : : improved architecture over the Oracle XML v1 parser and
    has
    : : : shown better performance on small to large XML documents.
    : It
    : : : will also be able to format the XML document according to
    a
    : : : stylesheet, having integrated an XSLT processor.
    : : : Version 2 of the XML Parser for Java, besides
    incorporating
    : an
    : : : XSLT processor, has been re-architected from version 1.
    This
    : : has
    : : : resulted in a number of changes to the class names
    : especially
    : : : those that support Namespaces. See v2changes.txt and
    : the .diff
    : : : difference files in the sample directory.
    : : : Oracle XML Team
    : : : http://technet.oracle.com
    : : : Oracle Technology Network
    null

  • Still problems serializing xml-docs with xml-parser for java v2.0.2.7

    Hi !
    I'm using the Oracle XML Parser 2.0.2.7.0 and get some problems when serializing the XMLDocument.
    In one class (DOMOut) I parse a xml-file with the oracle.xml.parser.v2.DOMParser, then obtain the XMLDocument and write it to System.out
    In another class (DOMIn) I fetch the XMLDocument from System.in, search for a given Element and print it's TextValue (if existing) to System.out
    That is where the error occurs.
    I get the XMLDocument from System.in but the returning NodeList from doc.getElementsByTagName() is empty. [nl.getLength()==0] even if it shouldn't be.
    Look at this code and output:
    [DOMOut]
    DOMParser parser = new DOMParser();
    parser.parse(url);
    XMLDocument doc = (XMLDocument)parser.getDocument();
    ObjectOutputStream out = new ObjectOutputStream(System.out);
    out.writeObject(doc); out.flush();
    [DOMIn]
    ObjectInputStream in = new ObjectInputStream(System.in);
    XMLDocument doc = (XMLDocument)in.readObject();
    doc.print(System.out);
    NodeList nl = doc.getElementsByTagName("Name");
    System.out.println("Length of NodeList: "+nl.getLength());
    if (nl.getLength()==0)
    System.out.println(argv[0] + ": not in this document!");
    else {
    XMLNode node = (XMLNode) nl.item(nl.getLength()-1);
    System.out.println(node.getNodeName() + ": " + (node.getFirstChild()).getNodeValue());
    This is the relevant code.
    I javac both classes and then do this:
    java DOMOut xmltestfile.xml > xx
    java DOMIn Name < xx
    And get this as output:
    <?xml version = '1.0'?>
    <!DOCTYPE course [
    <!ELEMENT course (Name,Dept,Instructor,Student)>
    <!ELEMENT Name ((#PCDATA)*)*>
    <!ELEMENT Dept ((#PCDATA)*)*>
    <!ELEMENT Instructor (Name)>
    <!ELEMENT Student (Name)*>
    ]>
    <course>
    <Name>Calculus</Name>
    <Dept>Math</Dept>
    <Instructor>
    <Name>Jim Green</Name>
    </Instructor>
    <Student>
    <Name>Jack</Name>
    <Name>Mary</Name>
    <Name>Paul</Name>
    </Student>
    </course>
    Length of NodeList: 0
    Name: not in this document!
    Has anyone an idea?
    If I do all this stuff without serializing it works.
    If I do not search for argv[0], but the string "Name" it fails.
    If I do search for "*" it works fine!
    I'm very confused could anybody please help me a bit??
    Stefan.
    [[email protected]]

    The link has been fixed. You will go to the v2 download page
    now. Sorry for the inconvience.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Renilton Oliveira (guest) wrote:
    : I didn't find the file for version 2.0.0.0 as well.
    : Renilton
    : Andrei Filimonov (guest) wrote:
    : : I tried to download XML Parser for Java v2 it seems that
    only
    : v
    : : 1.0.1.4 is available. Could you please give an exact URL for
    : v2
    : : download?
    : : Andrei Filimonov
    : : Oracle XML Team wrote:
    : : : The Oracle XML v2 parser is now available for download
    here
    : as
    : : : an early beta release and is written in Java. It features
    : an
    : : : improved architecture over the Oracle XML v1 parser and
    has
    : : : shown better performance on small to large XML documents.
    : It
    : : : will also be able to format the XML document according to
    a
    : : : stylesheet, having integrated an XSLT processor.
    : : : Version 2 of the XML Parser for Java, besides
    incorporating
    : an
    : : : XSLT processor, has been re-architected from version 1.
    This
    : : has
    : : : resulted in a number of changes to the class names
    : especially
    : : : those that support Namespaces. See v2changes.txt and
    : the .diff
    : : : difference files in the sample directory.
    : : : Oracle XML Team
    : : : http://technet.oracle.com
    : : : Oracle Technology Network
    null

  • JSR 172 XML parser in WTK 2.5: problems compared to 2.2 (part 2)

    Hi,
    I'm experiencing 2 problems with the WTK 2.5 JSR 172 XML parser that do not occur with:
    -WTK 2.2
    -Sony-Ericsson Emulator WTK2
    -Sony-Ericsson devices.
    They are:
    1- attributes.getLocalName(i) always returns an empty string
    I tried:
    parserFactory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
    -> still the same
    Then I tried:
    parserFactory.setFeature("http://xml.org/sax/features/namespaces", true);
    with this I get an exception when I try to create a parser.
    2- documents with multiple roots cause a parser panic.
    It is widely known that an XML document MUST NOT have multiple roots.
    I know. So what you're saying is they fixed a bug...
    Still, since devices and the WTK 2.2 doesn't have it, I was hoping there might be a backwards-compatiblity mode.
    I am trying to use the XML parser to parse a small HTML subset. If at least the panic Exception reported the position in the stream, maybe I could just start parsing again from there.
    The point is, why has ist changed, and will the change move to all implementations.
    Anyone has a hunch?
    Thanks a lot,
    Philippe

    Hi,
    I'm experiencing 2 problems with the WTK 2.5 JSR 172 XML parser that do not occur with:
    -WTK 2.2
    -Sony-Ericsson Emulator WTK2
    -Sony-Ericsson devices.
    They are:
    1- attributes.getLocalName(i) always returns an empty string
    I tried:
    parserFactory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
    -> still the same
    Then I tried:
    parserFactory.setFeature("http://xml.org/sax/features/namespaces", true);
    with this I get an exception when I try to create a parser.
    2- documents with multiple roots cause a parser panic.
    It is widely known that an XML document MUST NOT have multiple roots.
    I know. So what you're saying is they fixed a bug...
    Still, since devices and the WTK 2.2 doesn't have it, I was hoping there might be a backwards-compatiblity mode.
    I am trying to use the XML parser to parse a small HTML subset. If at least the panic Exception reported the position in the stream, maybe I could just start parsing again from there.
    The point is, why has ist changed, and will the change move to all implementations.
    Anyone has a hunch?
    Thanks a lot,
    Philippe

Maybe you are looking for