Using XSLT to extract value of a XML node with namespace

I have a XML source code here.
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:job="http://www.pageuppeople.com">
  <channel>
    <title>SMH Jobs</title>
    <link>internalrecruitment.smhgroup.com.au/jobsrss.ashx?stp=di</link>
    <description>A listing of jobs available here</description>
    <item>
      <title>eCommerce Optimisation Advisor</title>
      <description>A new and exciting opportunity exists for an experienced eCommerce Advisor to join</description>
      <job:location PUReferenceID="3711">Sydney - Inner Suburbs & CBD</job:location>
    </item>
  </channel>
</rss>
I want to use XSLT to extract value of a XML node with namespace <job:location>, and the returned value should be string 'Sydney - Inner Suburbs & CBD'. I tried a few XSL code below, but failed with error or nothing was returned.
<xsl:value-of select="job:location" disable-output-escaping="yes"/>
<xsl:value-of select="job/location" disable-output-escaping="yes"/>
<xsl:value-of select="job\location" disable-output-escaping="yes"/>
<xsl:value-of select="location" disable-output-escaping="yes"/>
This might be an easy question for you, but I would appreciate if anyone can help.

Hi Suncorp IT Learner,
We need to tell the XSLT that some elements are in another namespace. Copy the xmls declarations for the prefixes you need to use. Then use the xsl format as:
<xsl: value-of select=”job:location/@PUReferenceID”/>
In following issue, Chriztian has a good explanation:
http://our.umbraco.org/forum/developers/xslt/33353-XSLT-reading-XML-attribute-value
Thanks,
Qiao Wei
TechNet Community Support

Similar Messages

  • How to set the value in the xml node.

    Hi
    I am having the application PDF which can be submitted by user using the button. while submitting 
    i am using below code to set the value in the xml node.
       xfa.data.assignnode("employee.id","123",0):
    So its generating the xml like below.
    <employee>.
    <id>123</id>.
    </name>
    </employee>
    Now i need to generate the xml like  below.
    <employee id= "123" >
      </Name>
    </employee>
    So how to set/create the id node like above?
    Advance Thanks.
    Regards,
    Dhiyane

    Hi Dhiyane,
    You will have to set the contains property if the id node to "metaData", that is;
    xfa.data.assignNode("employee.id","123",0);
    xfa.data.employee.id.contains = "metaData";
    Very clumsy if you have a number of them, in which case you might want to look at using E4X.
    Good luck
    Bruce

  • Unstructured Xml Storage with Namespaces - Problem in DML Queries

    Hai All,
    I worked with xml namespace with registering schema in db and referred in my xml document.It worked fine.
    But i want to work in unstructured xml document with namespaces, to do all dml queries like, select,update,delete using Xpath to xmltype.
    I could insert the records,When i try to select some element from xmltype field using Xptah from db,it does not bring any thing like element value or any error.It just displaying as empty value.I am using oracle 10g R2.
    Please help me how to select the element value from xmltype using XPath or whatever it is.
    Please help me out from this to follow
    Advance Thanks,
    P.Savananan

    SQL> create user marco identified by marco account unlock;
    User created.
    SQL> grant dba, xdbadmin to marco;
    Grant succeeded.
    SQL> conn marco/[email protected]
    Connected.
    SQL> create table xml_tab ( details xmltype);
    Table created.
    SQL> insert into xml_tab values(XMLTYPE('<?xml version="1.0" ?>
      2  <customers xmlns="http://localhost/openuri.org" >
      3  <customer>
      4  <order xmlns="http://orcl.com" >
      5  <ordername>Computer</ordername>
      6  <cost>35785638</cost>
      7  </order>
      8  </customer>
      9  </customers>'));
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select extractValue(details,'/customers/customer/order/ordername') from xml_tab;
    EXTRACTVALUE(DETAILS,'/CUSTOMERS/CUSTOMER/ORDER/ORDERNAME')
    SQL> set long 10000
    SQL> select * from xml_tab;
    DETAILS
    <?xml version="1.0"?>
    <customers xmlns="http://localhost/openuri.org">
      <customer>
        <order xmlns="http://orcl.com">
          <ordername>Computer</ordername>
          <cost>35785638</cost>
        </order>
      </customer>
    </customers>
    SQL> select extract(details,'//order/ordername') XDATA
      2  from   xml_tab
      3  ;
    XDATA
    SQL> select extract(details,'//order/ordername','xmlns="http://orcl.com"') XDATA
      2  from   xml_tab
      3  ;
    XDATA
    <ordername xmlns="http://orcl.com">Computer</ordername>
    SQL> select extractValue(details,'//order/ordername','xmlns="http://orcl.com"') XDATA
      2  from   xml_tab
      3  ;
    XDATA
    Computer
    SQL> select extractValue(details,'/*/*/order/ordername','xmlns="http://orcl.com"') XDATA
      2  from   xml_tab
      3  ;
    XDATA
    Computer

  • Need help in extracting value from an xml tag.

    Hi ALL,
    Good Morning to all, i have problem in fetching a value from a xml tag. I have created a xml schema based on the schema i have created a xmltype table and inserted a value to the table. When i am trying to fetch a value from a particular tag i am unable to do so.. Kindly help me to solve this. Here by i am posting all the workings i have done...
    I am using the following client:
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Jan 31 11:44:59 2011
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    ////////////////////////////////// XML Schema ///////////////////////
    begin
    dbms_xmlschema.registerSchema(
    'http://www.oradev.com/chipsxml.xsd',
    '<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.oradev.com/chipsxml.xsd"
    xmlns:samp="http://www.oradev.com/chipsxml.xsd"
    version="1.0">
    <element name="Field1">
    <complexType>
    <sequence>
         <element name="UTI">
              <complexType>
              <sequence>
              <element name = "U01" type = "string"/>
              <element name = "U02" type = "string"/>
              <element name = "U03" type = "string"/>
              <element name = "U03a" type = "string"/>
              <element name = "U03b" type = "string"/>          
              <element name = "U03c" type = "string"/>          
              <element name = "U04" type = "string"/>                    
              <element name = "U05" type = "string"/>                    
              </sequence>
              </complexType>
         </element>
    </sequence>
    </complexType>
    </element>
    </schema>',
    TRUE, TRUE, FALSE, FALSE);
    end;
    ////////////////////////// Table which has multiple Column //////////////////////////
    CREATE TABLE chipsxmltable1 (
    id number, XMLDATA XmlType)
    XMLTYPE XMLDATA STORE AS OBJECT RELATIONAL
    XMLSCHEMA "http://www.oradev.com/chipsxml.xsd"
    ELEMENT "Field1";
    ///////////////////////////////// Insert Query in chipsxmltable //////////////////////////
    INSERT INTO chipsxmltable VALUES(
    xmltype.createxml('<?xml version="1.0"?>
    <samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd" >
    <UTI>
    <U01>No</U01>
    <U02>Y</U02>
    <U03>Y</U03>
    <U03a>Y</U03a>
    <U03b>Y</U03b>
    <U03c>Y</U03c>     
    <U04>Y</U04>
    <U05>Y</U05>          
    </UTI>
    </samp:Field1>'));
    To show the data as a field with structure:
    1. Query:
    Select * from chipsxmltable1;
    Output:
    ID XMLDATA
    1 <?xml version="1.0"?>
    <samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd">
    <UTI>
    <U01>No</U01>
    <U02>No</U02>
    <U03>Y</U03>
    <U03a>Y</U03a>
    <U03b>Y</U03b>
    <U03c>Y</U03c>
    <U04>Y</U04>
    <U05>Y</U05>
    </UTI>
    </samp:Field1>
    2. Query: (Both the query displays the same Output)
         SELECT X.xmldata.getClobVal() "XMLDATA" FROM chipsxmltable1 X;
         select extract(XMLDATA, '/Field1').getstringval() "XMLDATA" from chipsxmltable1 x;
    Output:
    XMLDATA
    <?xml version="1.0"?>
    <samp:Field1 xmlns:samp="http://www.oradev.com/chipsxml.xsd">
    <UTI>
    <U01>No</U01>
    <U02>No</U02>
    <U03>Y</U03>
    <U03a>Y</U03a>
    <U03b>Y</U03b>
    <U03c>Y</U03c>
    <U04>Y</U04>
    <U05>Y</U05>
    </UTI>
    </samp:Field1>
    To show the data as a single string without structure using "getstringval()":
    3. Query
         select extract(XMLDATA, '//text()').getstringval() "CHIPS - XML" from chipsxmltable1 x;
    OUtput:
    CHIPS - XML
    NoNoYYYYYY
    To show the data as a single string without structure using "getclobval()":
    4.Query
         select extract(XMLDATA, '//text()').getClobVal() "CHIPS - XML" from chipsxmltable1 x;
    Output:
    CHIPS - XML
    NoNoYYYYYY
    To show the data in a particular tag with/Without structure (Which is not working) using "EXTRACT" function:
    6.Query:
         select extract(XMLDATA, '/Field1/text()').getstringval() "XMLDATA" from chipsxmltable1 x;
         select extract(XMLDATA, '/Field1/UTI').getstringval() "XMLDATA" from chipsxmltable1 x;
         select extract(XMLDATA, '/Field1/UTI/U01').getstringval() "XMLDATA" from chipsxmltable1 x;
         select extract(XMLDATA, '/Field1/UTI/U01/text()').getstringval() "XMLDATA" from chipsxmltable1 x;
    Output:
    CHIPS - XML
    The above queries are not fetching the value.
    To show the data in a particular tag with/Without structure (Which is not working) using "EXTRACTVALUE" function:
    7. Query:
         select extractValue(XMLDATA, '/Field1/UTI') "XMLDATA" from chipsxmltable1 x;
         select extractValue(XMLDATA, '/Field1/UTI/U01') "XMLDATA" from chipsxmltable1 x;
    Output:
    X
    The above queries are not fetching the value.
    My question is:
    How to fetch values from xml tag when the value are inserted through xml schema?
    Apologies if the description is not clear. Kindly let me know if further details are needed. Many thanks for your help.
    Very best regards,
    Godwin Jebakumar C.V.

    Hi,
    You need to declare the namespace of each element used in the XPath expression, like this :
    SQL> select extractvalue( XMLDATA
      2                     , '/samp:Field1/UTI/U01'
      3                     , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"' ) "XMLDATA"
      4  from chipsxmltable1 x
      5  ;
    XMLDATA
    No
    SQL> select extract( XMLDATA
      2                , '/samp:Field1/UTI'
      3                , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"'
      4                ).getstringval() "XMLDATA"
      5  from chipsxmltable1 x
      6  ;
    XMLDATA
    <UTI>
      <U01>No</U01>
      <U02>Y</U02>
      <U03>Y</U03>
      <U03a>Y</U03a>
      <U03b>Y</U03b>
      <U03c>Y</U03c>
      <U04>Y</U04>
      <U05>Y</U05>
    </UTI>
    Please see EXTRACT and EXTRACTVALUE documentation :
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions051.htm#i1006712
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions052.htm#SQLRF06173
    BTW, "XMLDATA" is a pseudo-column used by Oracle. I don't know if it'll ever cause any conflict but maybe you should rename your column.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns010.htm#SQLRF00256
    Regards.

  • Using XPATH to extract value.

    I need some help to extract the LatestFillQuantity element value using XPATH.
    in Java.
    I am unable to extract the value of 10000.
    Please help as to what have I done wrong.?
    The Document configNode contains the flwg:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <i:Interest >
         <i:Generation>3</i:Generation>
         <i:Extension>
            <i:Active.From/>
            <i:Order>
              <i:Status>Confirm</i:Status>
              <i:LatestFillQuantity>100</i:LatestFillQuantity>
            </i:Order>
    </i:Extension>
    </i:Interest>
    My Java Code
    private void extractValue(Document configNode)
         XPathFactory factory = XPathFactory.newInstance();
            XPath xpath = factory.newXPath();
              try{
             XPathExpression expr
              = xpath.compile("//i:Order/i:LatestFillQuantity/text()");
             Object result = expr.evaluate(configNode, XPathConstants.NODESET);
             NodeList nodes = (NodeList) result;
             for (int i = 0; i < nodes.getLength(); i++) {
                 System.out.println(nodes.item(i).getNodeValue());
             }catch(Exception e){
                  System.out.println("Sorry,this aint working");
         }

    The nodes being parsed are namespace prefixed.
    To parse a namespace node with the JDK 5.0 javax.xml.xpath package, set the NamespaceContext on the XPath object.
    An implementation of NamespaceContext with a single prefix corresponding to a namespace uri:
    public class NamespaceContextImpl implements NamespaceContext{
    public String uri;
    public String prefix;
    public NamespaceContextImpl(){}
    public NamespaceContextImpl(String prefix, String uri){
         this.uri=uri;
         this.prefix=prefix;
    public String getNamespaceURI(String prefix){
       return uri;
    public void setNamespaceURI(String uri){
       this.uri=uri;
    public String getPrefix(String uri){
       return prefix;
    public void setPrefix(String prefix){
       this.prefix=prefix;
    public Iterator getPrefixes(String uri){return null;}
    }

  • How to search for a text node with a particular value in an xml document with labview

    supposing i have the following xml document:
    <head>
    <book>
    <bookname>zio</bookname>
    <author>dan</author>
    </book>
    <book>
    <bookname>the spear warrior</bookname>
    <author>britney</author>
    </book>
    <book>
    <bookname>the beard</bookname>
    <author>derrick</author>
    </book>
    </head>
    i want to search for the author of the book "the beard" using for example the V.I Get first match  of labview to access the the node with value "the beard" and then use Get next sibling  V.I  and Get node text content to get get the author of this book..so my question is how do i write the xpath expression for Get first match so as to access the node with bookname "the beard" instantyly?  am trying to minimise the use of loops because they increase the time duration,..thank you (NB:i dont want to use Get all Matched V.I because it obliges me to use a loop in order to access the name derrick and this increases the time duration for my v.i)
    Solved!
    Go to Solution.

    Since it's all text, why not use a real quick Match Pattern (or Regular Expression, but you don't need that much power here), see attached.
    Cameron
    To err is human, but to really foul it up requires a computer.
    The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
    Profanity is the one language all programmers know best.
    An expert is someone who has made all the possible mistakes.
    To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):
    LabVIEW Unit 1 - Getting Started
    Learn to Use LabVIEW with MyDAQ
    Attachments:
    Two-stage match demo.vi ‏8 KB

  • Getting null value while parsing "XML String" with  encoding WINDOWS-1252.

    Hi,
    when I am converting the Follwoing "xml string " to Document, I am getting the "null" as a document value.
        String strXML =  "<?xml version="1.0" encoding="WINDOWS-1252"?>
                              <category name="SearchByAttributes" value="Search By Attributes">
                                <item name="ORDER_LINE_ID" description="Application Search Attributes" >
                                   <attribute name="Sequence" value="0001"/>
                                 </item>
                                </category>"      
    My "xml string" has the encoding vaule: WINDOWS-1252.
    I am using the following code to convert the "xml string" to Document. I am getting the Document values as a "null" while converting the above "string xml"
            String strXML = //my above string xml.
            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            docBuilderFactory.setIgnoringElementContentWhitespace(true);
            docBuilder = docBuilderFactory.newDocumentBuilder();
            doc = docBuilder.parse(new InputSource(new StringReader(strXML)));              
            System.out.println("doc value.."+doc)//I am getting null value for "doc".
    Can anyone help me to resolve the issue.

    Thagelapally wrote:
    I am coverting the below "XML string" to Document, once it is converted I am reading that Document,which have an "attribue" Element in.
      String strXML = "<?xml version="1.0" encoding="WINDOWS-1252"?>
    <category name="SearchByAttributes" value="Search By Attributes">
    <item name="ORDER_LINE_ID" description="Application Search Attributes" >
    <attribute name="Sequence" value="0001"/>
    </item>
    </category>" I am using the above code to read the Document. When run the code in "OC4J Server" and using Jdeveloper as an editor,I am able to perfectly read the "attribute" element in the document with out any problem.Println statement printing as I expected.
    System.out.println("Element Name..."+listOfAtt.getNodeName());
    //getting Element Name as...."attribute"(as expected)
    System.out.println("Element Attibrute list....."+elementAtt);
    //getting Element Attribute list as an...."oracle.xml.parser.v2.XMLAttrList@afe"But when run the same code(reading the same Document) in Tomcat and Eclipse,println satatement not printing as i expected.
    System.out.println("Element Name..."+listOfAtt.getNodeName());
    //getting Element Name as...."#text"(I am expecting output value "attribute" but it is printing "#text" which i don't know)
    System.out.println("Element Attibrute list....."+elementAtt);
    //getting Element Attribute list as an...."null"(I am expecting output value object reference but it is printing "null"
    (without the rest of the code, i'm guessing that) most likely you are grabbing the first child node of the item element. however, you are not accounting for some text nodes that are most likely in that list, like the whitespace between the item element and the attribute element. please go read some tutorials on xml, there are thousands of them out there, and they will answer all you initial questions much more efficiently than posting each step to the forums.

  • Is it possible to create indexes & use them on xml docs with namespaces?

    I have put an XML doc in a BDBXML container which looks like this:
    *<ns1:note xmlns:ns1="http://www.testsch.org/ns">*
    *<ns1:to>Eric</ns1:to>*
    *<ns1:from>Brendan</ns1:from>*
    *<ns1:msg>How r u?</ns1:msg>*
    *</ns1:note>*
    Now, I am creating an index on the element "to", as:
    addIndex "ns1" "to" node-element-equality-string
    Though the index has been shown as getting created using the listIndexes command, if I lookup that index with the following command:
    lookupIndex node-element-equality-string "ns1" "to"
    the output is:
    *0 objects returned for eager index lookup 'node-element-equality-string'*
    Whereas, if I do the whole procedure without the namespaces in the document & the commands, the result is fine:
    *1 object returned for eager index lookup 'node-element-equality-string'*
    Can someone please tell me whether using namespaces, the indexes can be created or not? If yes, how?
    Thanks,
    Dev
    Edited by: user11871332 on Sep 7, 2009 3:53 PM

    Hi Dev,
    When using XML, the prefix for the namespace is really just syntactic sugar. The actual namespace in your example is "http://www.testsch.org/ns", and that's the value that you need to use when creating your index:
    addIndex "http://www.testsch.org/ns" "to" node-element-equality-stringJohn

  • Add indent spaces to xml nodes with ms IXMLDOM

    Hi All,
      Currently I was update a xml file with IXMLDOM, after add nodes to xml file, we found the new added node was written in one line always.  this make it hard to find the differences with merge tools.
      and after we try to add text node to the xml to format it, it works unless we added nested nodes, it looks like:
    <RootNode>
    <ChildNodes>
    <Child>value</Child></ChildNodes></RootNode>
    Ugly, huh
    And, when we set node's type with IXMLDOMNode::put_dataType it makes the node like:
    <Name xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string" Encoding="Standard" >Connections</Name>
    but, the original nodes was: 
    <Name dt:dt="string" Encoding="Standard" xmlns:dt="urn:schemas-microsoft-com:datatypes">Connections</Name>
    Also, it will not affect the its function, just cause extra efforts to merge the results.
    So my questions:
       1. is there any built-in functions that can be used to format the xml file to a indented version. 
       2. how to adjust the sequences of attributes of a node.
    Thanks, 
    Levi
    PS: currently, I was working on Windows CE 6.0, and these issues met on desktop OS too.
    One world, one dream

    >   1. is there any built-in functions that can be used to format the xml file to a indented version. 
    I used to use this code in a previous version of a project. I don't
    know if CE 6 will support it though.
    static bool FormatDOMDocument( MSXML2::IXMLDOMDocument *pDoc )
        // Create the writer
        CComPtr <IMXWriter> pMXWriter;
        if (FAILED (pMXWriter.CoCreateInstance(__uuidof (MXXMLWriter),
    NULL, CLSCTX_ALL)))
            return false;
        CComPtr <ISAXContentHandler> pISAXContentHandler;
        if (FAILED (pMXWriter.QueryInterface(&pISAXContentHandler)))
            return false;
        CComPtr <ISAXErrorHandler> pISAXErrorHandler;
        if (FAILED (pMXWriter.QueryInterface (&pISAXErrorHandler)))
            return false;
        CComPtr <ISAXDTDHandler> pISAXDTDHandler;
        if (FAILED (pMXWriter.QueryInterface (&pISAXDTDHandler)))
            return false;
        if (FAILED (pMXWriter->put_omitXMLDeclaration (VARIANT_FALSE))
    ||
            FAILED (pMXWriter->put_standalone (VARIANT_TRUE)) ||
            FAILED (pMXWriter->put_indent (VARIANT_TRUE)) ||
            FAILED (pMXWriter->put_encoding (L"UTF-8")))
            return false;
        // Create the SAX reader
        CComPtr <ISAXXMLReader> pSAXReader;
        if (FAILED(pSAXReader.CoCreateInstance(__uuidof
    (SAXXMLReader), NULL, CLSCTX_ALL)))
            return false;
        if (FAILED(pSAXReader->putContentHandler
    (pISAXContentHandler)) ||
            FAILED(pSAXReader->putDTDHandler (pISAXDTDHandler)) ||
            FAILED(pSAXReader->putErrorHandler
    (pISAXErrorHandler)) ||
            FAILED(pSAXReader->putProperty(
    reinterpret_cast<unsigned short*>(
    L"http://xml.org/sax/properties/lexical-handler" ), CComVariant
    (pMXWriter))) ||
            FAILED(pSAXReader->putProperty(
    reinterpret_cast<unsigned short*>(
    L"http://xml.org/sax/properties/declaration-handler" ), CComVariant
    (pMXWriter))))
            return false;
        // Perform the write
        bool success1 = SUCCEEDED( pMXWriter->put_output(
    CComVariant(pDoc ) ) );
        bool success2 = SUCCEEDED( pSAXReader->parse( CComVariant(
    pDoc ) ) );
        return success1 && success2;
    Dave

  • Parsing XML Node with href attribute

    Hi,
    I have the following XML that has to be parsed using JSP DOM. All fine except for one. The only problem that i have is when to parsing the Node with href attribute.
    I am using the following method, and it returned with weird result
    currNode.getAttributes() ====> the result is com.sun.org.apache.xerces.internal.dom.AttributeMap@111ae04
    currNode.getNodeValue() ====> the result is null
    currNode.TextNode ===> it returned *2*
    Can anyone please let me know what did I miss here? What should I do to parse the href attribute into the jsp page?
    The below is the xml.
    <MovieList>
    <Movie href="DarkKnight.xml">
       <head>
             <Title>Batman Dark Knight</Title>
             <Genres>
                   <Genre>Action</Genre>
                   <Genre>Sci-Fi</Genre>
             </Genres>
             <Description>Movie Details here</Description>
       </head>
    </Movie>
    </MovieList>Thanks

    I am not sure what "JSP DOM" is exactly. In the W3C DOM supported since SUN Java 1.4 if you have an element node and want to access an attribute value you can simply use String href = movieElement.getAttribute("href"); You might need to cast your Node to Element first e.g.Element movieElement = (Element)currNode;

  • How must getElementsByTagName work on an xml file with namespaces?

    Hello together,
    is there any normative document, which specifies
    which nodes must be returned by
    the org.w3c.dom.Document method
    getElementsByTagName when which was
    created by a namespace aware dom parser
    from an xml file containing namespaces?
    In other words:
    when you have an xml file:
    <someprefix:somenode xmlns:someprefix="http://someuri">
    <someprefix:innertag>
    <someprefix:mostinnertag>
    </someprefix:mostinnertag>
    <someprefix:mostinnertag>
    </someprefix:mostinnertag>
    </someprefix:innertag>
    </someprefix>
    and you call
    document.getElementsByTagName( ... );
    1) How many nodes must be returned when giving
    "mostinnertag" as parameter?
    2) How many nodes when giving "someprefix:mostinnertag" as parameter?
    Is it allowed to use the "non namespaceaware"
    method and not "getElementsByTagNameNS"?
    I know:
    a) xerces returns 2 nodes when using
    alternative 2 and none with alternative 1
    b) oracle xml parser returns 2 nodes when using
    alternative 1 and none when using alternative 2
    Which implementation is right?
    Yours
    Stefan

    I've got some problems with this methos and xerces too.
    Perhaps the two implementations (xerces and oracle) are different. I mean xerces implementation gives you nodes of this name but without namespace and oracles's implementation gives you modes with namespace whose unprefix-name is "mostinnertag".

  • Selecting XML Children with Namespaces

    I am trying to select child nodes of an XML element that have
    a different namespace from the parent, but xml.child(name) returns
    an empty list.
    In the attached code, londonList contains a single XML
    element and parisList is empty. I can't figure out how to find the
    paris child, and have tried adding the prefix to findParis (so it
    is "ff:b") as well as turning findParis into an XML object with the
    name "b" and adding the ff namespace to it, then passing that to
    child. Neither of those have worked.
    Any help is appreciated.

    Unfortunately in my real scenario I don't know what the
    element will be called. It could be in <foo> or <bar>
    etc, so I need to be able to use a variable (in which the element
    name is set beforehand). With "::" I can't use a variable, so
    textXML.ns::findParis looks for a "findParis" element and not "b".
    That's why I'm trying to use testXML.child(findParis) because
    I can use a variable. I just can't figure out how to make it
    incorporate the namespace as well.

  • How to use XSLT processor in java to get xml

    hi friends,
    i have raw xml and xsl files as input to xsltprocessor which should give xml as output.
    my raw xml and xsl looks like this:-
    name_space.xml:-
    <xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
    xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
    xmlns:rs='urn:schemas-microsoft-com:rowset'
    xmlns:z='#RowsetSchema'>
    <s:Schema id='RowsetSchema'>
    <s:ElementType name='row' content='eltOnly'>
    <s:AttributeType name='ID' rs:number='1' rs:nullable='true'
    rs:writeunknown='true'>
    <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
    rs:fixedlength='true'/>
    </s:AttributeType>
    <s:AttributeType name='CODE' rs:number='2' rs:nullable='true'
    rs:writeunknown='true'>
    <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
    </s:AttributeType>
    <s:AttributeType name='NAME' rs:number='3' rs:nullable='true'
    rs:writeunknown='true'>
    <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='255'/>
    </s:AttributeType>
    <s:AttributeType name='SOURCE' rs:number='4' rs:nullable='true'
    rs:writeunknown='true'>
    <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='10'/>
    </s:AttributeType>
    <s:AttributeType name='IDENT' rs:number='5' rs:nullable='true'
    rs:writeunknown='true'>
    <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='128'/>
    </s:AttributeType>
    <s:AttributeType name='OBS_LEVEL' rs:number='6' rs:nullable='true'
    rs:writeunknown='true'>
    <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='50'/>
    </s:AttributeType>
    <s:AttributeType name='ATA_CODE' rs:number='7' rs:nullable='true'
    rs:writeunknown='true'>
    <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='12'/>
    </s:AttributeType>
    <s:AttributeType name='SCORE' rs:number='8' rs:nullable='true'
    rs:writeunknown='true'>
    <s:datatype dt:type='int' dt:maxLength='4' rs:precision='10'
    rs:fixedlength='true'/>
    </s:AttributeType>
    <s:AttributeType name='HAS_EFF_NOTE' rs:number='9' rs:nullable='true'
    rs:writeunknown='true'>
    <s:datatype dt:type='ui1' dt:maxLength='1' rs:precision='3'
    rs:fixedlength='true'/>
    </s:AttributeType>
    <s:extends type='rs:rowbase'/>
    </s:ElementType>
    </s:Schema>
    <rs:data>
    <z:row ID='1018' CODE='OBSV' NAME='ALT BRK - LOSS OF THE PEDAL ARTIFICIAL FEEL ON THE RIGHT SIDE'
    SOURCE='' IDENT='' OBS_LEVEL='' ATA_CODE='32-43' SCORE='1'
    HAS_EFF_NOTE='0'/>
    <z:row ID='1017' CODE='OBSV' NAME='ALT BRK - LOSS OF THE PEDAL ARTIFICIAL FEEL ON THE LEFT SIDE'
    SOURCE='' IDENT='' OBS_LEVEL='' ATA_CODE='32-43' SCORE='1'
    HAS_EFF_NOTE='0'/>
    <z:row ID='100' CODE='LOCAL' NAME='ACCU PRESS DROPS VERY QUICKLY PARKING BRAKE OFF'
    SOURCE='' IDENT='' OBS_LEVEL='INDICATOR(S)' ATA_CODE='32-44'
    SCORE='1' HAS_EFF_NOTE='0'/>
    </rs:data>
    </xml>
    and my XSL File:-
    <?xml version="1.0" encoding="UTF-8" ?>
    - <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" exclude-result-prefixes="rs z">
    <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />
    - <xsl:template match="//xml/rs:data">
    - <Entities Count="{count(z:row)}">
    <xsl:apply-templates select="z:row" />
    </Entities>
    </xsl:template>
    - <xsl:template match="z:row">
    <Entity ID="{@ID}" ATA="{@ATA_CODE}" Name="{@NAME}" Code="{@CODE}" Source="{@SOURCE}" Ident="{@IDENT}" Level="{@OBS_LEVEL}" EffNote="{@HAS_EFF_NOTE}" Score="{@SCORE}" />
    </xsl:template>
    </xsl:stylesheet>
    AND I NEED OUTPUT XML AS:-
    <Entities Count="3">
         <Entity ID="1018" ATA="32-43" Name="ALT BRK - LOSS OF THE PEDAL ARTIFICIAL FEEL ON THE RIGHT SIDE" Code="OBSV" Source="" Ident="" Level="" EffNote="0" Score="1"></Entity>
         <Entity ID="1017" ATA="32-43" Name="ALT BRK - LOSS OF THE PEDAL ARTIFICIAL FEEL ON THE LEFT SIDE" Code="OBSV" Source="" Ident="" Level="" EffNote="0" Score="1"></Entity>
         <Entity ID="100" ATA="32-44" Name="ACCU PRESS DROPS VERY QUICKLY PARKING BRAKE OFF" Code="LOCAL" Source="" Ident="" Level="INDICATOR(S)" EffNote="0" Score="1"></Entity>
    </Entities>
    how to write a bean to get this xmloutput.
    thank in advance

    Hi Sliba,
    You may download and use the XDK for Java that is available from OTN to do this.
    Here is the code that will be handy for use. Just substitute your XML document and stylesheet
    in the code snippet pasted below. I hope this helps.
    There are many more useful XML samples you can find at http://otn.oracle.com/sample_code/tech/xml/content.html
    Regards
    Abhijeet
    // import the necessary libraries
    import oracle.xml.parser.v2.XSLProcessor;
    import oracle.xml.parser.v2.XSLStylesheet;
    import oracle.xml.parser.v2.XMLDocument;
    import oracle.xml.parser.v2.DOMParser;
    import java.io.StringReader;
    public class Test
    public Test()
    // Xml document that needs to be transformed
    private static String xmldoc = "<xml xmlns:s=\"http:www.myschema.com\" >" +
    "<s:result>" +
    "<s:status>1234554321</s:status>"+
    "<s:approvalcode>1234567887654321</s:approvalcode> "+
    "</s:result>" +
    "</xml>";
    // Xsl stylesheet that will be applied
    private static String xsldoc ="<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:s=\"http:www.myschema.com\" > " +
    " <xsl:template match=\"s:result\"> "+
    " My transform status: <xsl:value-of select=\"s:status\"/> <BR/>" +
    " My transform Approval code : <xsl:value-of select=\"s:approvalcode\"/> " +
    "</xsl:template> " +
    "</xsl:stylesheet> ";
    public void transform(String xmlstr,String xslstr) throws Exception {
    // Create the DOM parser instance
    DOMParser dp = new DOMParser();
    // Create StringReader object
    StringReader xmlreader = new StringReader(xmlstr);
    // Parse the xml document string
    dp.parse(xmlreader);
    // Get java object representation of XML document
    XMLDocument xmldoc = dp.getDocument();
    // Create an instance of XSL processor
    XSLProcessor processor = new XSLProcessor();
    // Create StringReader object
    StringReader xslreader = new StringReader(xslstr);
    // Parse the xsl stylesheet
    XSLStylesheet xsl = processor.newXSLStylesheet(xslreader);
    processor.showWarnings(true);
    processor.setErrorStream(System.err);
    processor.processXSL(xsl,xmldoc,System.out);
    return;
    public static void main(String[] args) throws Exception
    Test test = new Test();
    System.out.println("Executing test");
    test.transform(xmldoc,xsldoc);
    }

  • Retrieve xml attribute value of nth xml node using xpath query

    I have an xml with following stucture...
    <xml>
    <header>
     <DocumentReference OrderId="order001">
     <DocumentReference OrderId="order002">
     <DocumentReference OrderId="order003">
    I have to loop through this xml and retrieve the orderId values inside Biztalk orchestration.
    In the expression shape, I get the count of 'DocumentReference' nodes using an xpath query and then
    Added a loopshape to make sure it loops thru all nodes
    Loop condition:   n<=nodeCount     (where n is an integer variable, n=0 to begin with, incremented by 1 thru each loop, nodeCount is # of DocumentReference nodes)
     I try retrieve to the orderId in the following expression shape using the below xpath query
      xpathQuery = System.String.Format("//*[local-name()='OrderReference'][{0}]/@orderID)",n);
      sOrderId = xpath(MsgSingleInvoice,xpathQuery);
    And I get the following exception:
    Inner exception: '//*[local-name()='OrderReference'][1]/@orderID)' has an invalid token.
    Exception type: XPathException
    Appreciate any help!   thanks!

    Thanks for the quick response. I got rid of it.
    And I see a different error:
    Inner exception: Specified cast is not valid. Exception type: InvalidCastException
    Source: Microsoft.XLANGs.Engine  
    Target Site: System.Object XPathLoad(Microsoft.XLANGs.Core.Part, System.String, System.Type)
    Since variable 'n' is of integer type, I suspected it and changed it to n.ToString() and tested again and still see the same error.

  • How to get a value from Specific XML Node

    Hi all,
    I'm just trying to introduce to XMLType and see the potencialities of that.
    DB version:
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    CORE     10.2.0.5.0     Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Productio
    NLSRTL Version 10.2.0.5.0 - Production
    I'm a table with just one CLOB field:
    CREATE TABLE asm_test
    (doc XMLType NOT NULL)
    XMLTYPE doc STORE AS CLOB;
    Then i've inserted the following XML data:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ReceiptDesc>
    <appt_nbr>2142473</appt_nbr>
    - <Receipt>
    <dc_dest_id>401</dc_dest_id>
    <po_nbr>2142473</po_nbr>
    <document_type>P</document_type>
    <asn_nbr />
    - <ReceiptDtl>
    <item_id>509720</item_id>
    <unit_qty>83.0000</unit_qty>
    <receipt_xactn_type>R</receipt_xactn_type>
    + <receipt_date>
    <year>2012</year>
    <month>09</month>
    <day>17</day>
    <hour>15</hour>
    <minute>33</minute>
    <second>49</second>
    </receipt_date>
    <receipt_nbr>6902340</receipt_nbr>
    <container_id>1</container_id>
    <to_disposition>ATS</to_disposition>
    <user_id>NTCPO01</user_id>
    <catch_weight />
    </ReceiptDtl>
    - <ReceiptDtl>
    <item_id>509740</item_id>
    <unit_qty>17.0000</unit_qty>
    <receipt_xactn_type>R</receipt_xactn_type>
    + <receipt_date>
    <year>2012</year>
    <month>09</month>
    <day>17</day>
    <hour>15</hour>
    <minute>33</minute>
    <second>49</second>
    </receipt_date>
    <receipt_nbr>6902344</receipt_nbr>
    <container_id>1</container_id>
    <to_disposition>ATS</to_disposition>
    <user_id>NTCPO01</user_id>
    <catch_weight />
    </ReceiptDtl>
    </Receipt>
    </ReceiptDesc>
    And then i have started to make some tests to retrieve data from.
    SELECT EXTRACTVALUE(doc, '/ReceiptDesc/appt_nbr') FROM asm_test; -- got the correct value 2142473
    SELECT EXTRACTVALUE(doc, '/ReceiptDesc/Receipt/dc_dest_id') FROM asm_test; ---- got the correct value 401
    select count(*) from asm_jam_test d where (d.doc.getClobVal()) like '%NTCPO01%'; -- got 1
    But i need to find a Specific data from XML (the main goal is to update a value inside XML).
    If i try this:
    select extract(doc, '/ReceiptDesc/Receipt/ReceiptDtl/item_id/text()').getstringVal() from asm_test                     
    where existsNode(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr') = 1;
    got: 509720509740 -- which are the concatenate of 2 Item_ids
    when i try to find out the Item_id of specific receipt_nbr i got a NULL response.
    select extract(doc, '/ReceiptDesc/Receipt/ReceiptDtl/item_id/text()').getstringVal()
    from  asm_test                     
    where existsNode(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr') = 1 and
    extract(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr/text()').getstringVal() = '6902340';
    What i'm doing wrong or which is the best way to get data from XML?
    Many thanks in advance

    Hi,
    Thanks for providing db version and sample data in the first place.
    Don't forget to use the &#x7B;code} tags to preserve formatting.
    Also, when posting XML, do not copy/paste directly from your browser as it retains +/- signs and therefore needs extra processing on our side.
    select count(*) from asm_jam_test d where (d.doc.getClobVal()) like '%NTCPO01%'; -- got 1No, don't do it like that.
    Use existsNode() function in this situation :
    SQL> select count(*)
      2  from asm_test
      3  where existsNode(doc, '/ReceiptDesc/Receipt/ReceiptDtl[user_id="NTCPO01"]') = 1
      4  ;
      COUNT(*)
             1
    when i try to find out the Item_id of specific receipt_nbr i got a NULL response.Yes, that's because this :
    extract(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr/text()').getstringVal()returns :
    69023406902344So obviously it cannot be equal to '6902340'.
    When you have to deal with repeating nodes individually, use XMLTable function to break the structure into relational rows and columns.
    The resultset you'll get acts as a virtual table (or inline view) you can then manipulate with SQL operations :
    SQL> select x.*
      2  from asm_test t
      3     , xmltable(
      4         '/ReceiptDesc/Receipt/ReceiptDtl'
      5         passing t.doc
      6         columns item_id     varchar2(15) path 'item_id'
      7               , receipt_nbr varchar2(15) path 'receipt_nbr'
      8       ) x
      9  ;
    ITEM_ID         RECEIPT_NBR
    509720          6902340
    509740          6902344
    Now, you can just add a WHERE clause to filter the RECEIPT_NBR you require :
    SQL> select x.item_id
      2  from asm_test t
      3     , xmltable(
      4         '/ReceiptDesc/Receipt/ReceiptDtl'
      5         passing t.doc
      6         columns item_id     varchar2(15) path 'item_id'
      7               , receipt_nbr varchar2(15) path 'receipt_nbr'
      8       ) x
      9  where x.receipt_nbr = '6902340'
    10  ;
    ITEM_ID
    509720
    That can also be achieved with EXTRACTVALUE and a single XPath expression (assuming RECEIPT_NBR is unique) :
    SQL> select extractvalue(
      2           doc
      3         , '/ReceiptDesc/Receipt/ReceiptDtl[receipt_nbr="6902340"]/item_id'
      4         ) as item_id
      5  from asm_test
      6  ;
    ITEM_ID
    509720

Maybe you are looking for

  • How do you share photos so other users on computer can view photos in a shared folder?

    I have a Apple 2 TB Time Capsule running on a 27" iMAC. I contacted Apple Phone Support to help instruct me last month on how to set up a shared folder so all users on this computer and people connected to my network iwthin the home can share family

  • Error 1600 when trying to restore.

    I turned my iPod touch on this morning, listened to so music, then shut it off. About 2 hours later I go to turn it on and it just stays on a black screen, doesn't light up at all. I plug it into my PC thinking maybe it just needs to update or someth

  • Refreshing Materialized view from APEX process is causing errors

    Hi, I have created a materialized view, and am attempting to create a process in APEX to refresh the mview on a button click. I have been reading the documentation on Materialized Views and think I am more confused now than when I started. Do I need

  • How to create password for EXISTING address book application

    I want to password protect my address book as a whole or individual addresses/contacts. I can't find any documentation or prompts about how to do this.  Can anybody help? Solved! Go to Solution.

  • Reader Extensions to retrieve data from form?

    Hello Will it possible to retrieve the formdata of a PDF form by an external program if I have Adobe Reader Extensions? Thank you Sincerely Lore P.S.: Will this be possible also by Form Based Pricing Reader Extensions?