Validating namespace in XPATH

Hi,
How do I resolve the namespaces in the XPATH. I'm using Xalan 2.4 package and it's API. I made a simple test program where I pass the Xpath and I get back the node. The problem i'm facing is that if the xml document in question has some namespace declared. In the Xpath expression if I include the name space then it does not return the proper result. Where as when I give the Xpath without the namespace prefix it returns the node. I'm using the evaluate method of the XPathEvaluatorImpl class ( in package org.apache.xpath.domapi). This method takes XPathNSResolver (the namespace resolver) as one of the parameters. I passed that too still the problem persisted. If any one could help me out here it would be great. if you need further details I can post the code.

To answer my own question..
The mistake I was commiting was at a very upper level.
While creating the DOM..the Factory instance I was using was of the type which does not resolve the namespaces properly. That is why even though my XPATH objects had the resolver set properly still I was not able to get to the proper node.
Sorry If I wasted any one of you's time :)

Similar Messages

  • /BI0/ is not a valid namespace prefix for the organizational criterion

    Hi all,
    I'm getting the below error message when trying to transport 0bpartner that has a 0ORGUNIT as an attribute. I have come across some OSS notes, but those are not applicable to us. I was not able to implement the note is our system.
    We are on 7.3 SP5
    The error mesage is the following:
    Start of the after-import method RS_IOBJ_AFTER_IMPORT for object type(s) IOBJ ( )
    /BI0/ is not a valid namespace prefix for the organizational criterion
    Error SV 771 during after import handling of objects with type(s) IOBJ
    End of after import methode RS_IOBJ_AFTER_IMPORT (Aktivierungsmodus) - runtime: 00:12:19
    Any insight would be appreciated.
    Thanks,
    Voodi

    voodi wrote:
    Hi all,
    >
    > I'm getting the below error message when trying to transport 0bpartner that has a 0ORGUNIT as an attribute. I have come across some OSS notes, but those are not applicable to us. I was not able to implement the note is our system.
    >
    > We are on 7.3 SP5
    >
    >
    > The error mesage is the following:
    >
    >  Start of the after-import method RS_IOBJ_AFTER_IMPORT for object type(s) IOBJ ( )
    >  /BI0/ is not a valid namespace prefix for the organizational criterion
    >  Error SV 771 during after import handling of objects with type(s) IOBJ
    >  End of after import methode RS_IOBJ_AFTER_IMPORT (Aktivierungsmodus) - runtime: 00:12:19
    >
    >
    > Any insight would be appreciated.
    >
    > Thanks,
    > Voodi
    Hi Voodi,
    I strongly think this could be a authorzaiton issue.
    Have you checked the error log? More references : http://goo.gl/9554m ; SAP Note 731973
    Methods
    1. Activate and adjust table /bi0/pbpartner
    2. Activate and adjust table /bi0/morgunit
    3.Run program RSDG_IOBJ_ACTIVATE
    4 Repair info object using program RSDG_IOBJ_REORG
    5. If none of the above help run the program RSDMD_CHECKPRG_ALL with repair mode checked for 0ORGUNIT.
    Possible cases:
    1. Goto RSRV - SID Values in X and Y Tables for 0BPARTNER. If not try activation using RSDG_IOBJ_ACTIVATE
    2. Check changes : If you add new objects to 0BPARTNER then you should also collect that newly added object , collecting only 0BPARTNER is not enough.
    3. If 0BPARTNER is inactive in Q, pls collect it in a request and try to re transport and check.
    Best Regards, @{

  • Namespace-aware XPath expressions?

    In xMII 11.5.2 b64, I need to extract a node from a SOAP message:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:Header/>
       <soapenv:Body>
          <ns0:importRequest xmlns:ns0="http://www.acme.com/1.0/schemas">
            <FOO>
    The following xMII Assign action Link returns me the entire <FOO> nodeset:
    Transaction.SOAPRequest{/soapenv:Envelope/soapenv:Body/ns0:importRequest/*}
    However, I cannot be guaranteed that the namespace prefixes will always be "soapenv" and "ns0".  For example, the following is perfectly valid:
    <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
       <SOAP:Header/>
       <SOAP:Body>
          <ZZZ:importRequest xmlns:ZZZ="http://www.acme.com/1.0/schemas">
            <FOO>
    When they are changed the XPath fails.  I have tried the following:
    Transaction.SOAPRequest{/Envelope/Body/importRequest/*}
    Transaction.SOAPRequest{//importRequest/*}
    but they clearly don't work because the XPath evaluator in xMII is namespace aware (as it should be).
    How can I declare namespaces in my XPath expression?  Or are there any other alternate ideas?
    Thanks,
    -tim

    I installed SR3 and re-ran my tests and it still fails.  Here is my XML snippet:
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:sch="http://www.acme.com/4.3/schemas">
       <SOAP:Header/>
       <SOAP:Body>
          <sch:importIDOCRequest>
             <MATMAS03>
    Here's the output from various expressions in the Link editor:
    example 1 - getting the name of the root node:
    "root node name=" & Transaction.SOAPRequest{name(/*)}
    output 1 is predictable:
    [INFO ]: root node name=SOAP:Envelope
    example 2 - using 'senv' instead of 'SOAP' for the soap-envelope namespace prefix:
    "importRequest child node name=" & Transaction.SOAPRequest{name(/senv:Envelope/senv:Body/sch:importIDOCRequest/*)}
    output 2:
    [INFO ]: importRequest child node name=
    example 3 - no namespace prefixes specified:
    "importRequest child node name=" & Transaction.SOAPRequest{name(/Envelope/Body/importIDOCRequest/*)}
    output 3:
    [INFO ]: importRequest child node name=
    example 4 - using the same node namespaces prefixes as the input XML:
    "importRequest child node name=" & Transaction.SOAPRequest{name(/SOAP:Envelope/SOAP:Body/sch:importIDOCRequest/*)}
    output 4:
    [INFO ]: importRequest child node name=MATMAS03
    Any other ideas?
    -tim

  • Add Namespace in XPATH - Declaration - [JS]-CS4

    Dear All,
    Here I have a big doubt regarding for XPATH - Add Namespace in JavaScript.
    I have to written in Vb.NET
    //---------------- Add Namespace in VB.NET --------------------//
    Dim xDom As New XmlDocument
    Dim xNs As New XmlNamespaceManager(xDom.NameTable)
    xNs.AddNamespace("ce", "http://www.elsevier.com/xml/common/dtd")
    xNs.AddNamespace("aid", "http://adobe.com/4.0")
    AuthorNds = xDom.SelectNodes("//ce:author", xNs)
    //--------End
    and using the xNs in anywhere, But I can't declare the namespace in Javascript+XPATH.
    this.name = "AddReturns";
    //XPath will match on every XML element in the XML structure.
    this.xpath = "//ce:author";
    // Define the apply function.
    this.apply = function(myElement, myRuleProcessor)
    Only is there in the XPATHs. So How to use and insert the namespace in the Javascript + XPATH operations.
    Please kindly give me a suggestion to declare the XPATH in javascript....
    Thanks & Regards
    T.R.Harihara SudhaN

    Thanks for the reply! However, I need the soap envelope to have some additional namespaces defined as:
    original request:
    <soapenv:Envelope xmlns:soapenv="...">
    need this to go to the business service:
    <soapenv:Envelope xmlns:soapenv="..." xmlns:xsi="..." xmlns:xsd="...">
    Is there a predefined $variable for the envelope?
    thanks!

  • Can't find namespace for xpath function adjust-dateTime-to-timezone()

    I'm trying to "shift" the output of current-dateTime() to GMT. I believe the function listed above is the way to do it by using an empty string as the desired timezone. However, I can't find this function in JDev nor can I figure out what namespace it's supposed to have in the application server. Can anyone give advice?
    I'm using 10.1.3
    Thanks,
    Bret

    It is a Xpath 2 function. do you know whether your xpath processor supports 2 or not?

  • Matching namespace qualified xpaths vis JAXP xsl transforms

    I am having problems getting template
    matches to work when matching against
    namespace qualified tags. I am passing
    the source xml and xsl into a JAXP transformer.
    The xsl templates sucessfully match against non namespace
    qualified tags but not namespace qualified tags.
    I have set the DocumentBuilderFactory to be namespace aware. The xml source and the xsl source are loaded
    from the file system i.e. the DOM's are not
    built programmatically.
    Peter.

  • XPath and namespaces

    I am currently using:
    http://www.ibm.com/developerworks/library/x-javaxpathapi.html
    to figure out how to extract nodes from an xml with default namespace.
    I have this xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.21" id="1">
        <property name="createdBy">Eclipse BIRT Designer Version 2.5.2.v20100208 Build <2.5.2.v20100210-0630></property>
        <property name="units">in</property>
        <page-setup>
            <simple-master-page name="Simple MasterPage" id="2">
                                  <xml-property name="waht"> <![CDATA[I DON*T WANT THIS - MASTER]]></xml-property>
            </simple-master-page>
        </page-setup>          
        <body>
            <extended-item name="Book" id="7">
                <xml-property name="xmlRepresentation"><![CDATA[I DON*T WANT THIS - BOOK]]></xml-property>
                <property name="outputFormat">SVG</property>
            </extended-item>          
            <extended-item name="Chart" id="7">
                <xml-property name="xmlRepresentation"><![CDATA[I WANT THIS]]></xml-property>
                <property name="outputFormat">SVG</property>
            </extended-item>
        </body>
    </report>I am trying to extract the CDATA test for the element in Body where name = "Chart". Before evaluating the XPath expression I enable the following namespace context:
        xPath.setNamespaceContext(new NamespaceContext() {
          @Override
          public Iterator getPrefixes(String namespaceURI) {
            throw new UnsupportedOperationException();
          @Override
          public String getPrefix(String namespaceURI) {
            throw new UnsupportedOperationException();
          @Override
          public String getNamespaceURI() {
            if (prefix == null) throw new NullPointerException("Null prefix");
            else if ("property".equals(prefix)) return "http://www.eclipse.org/birt/2005/design";
            else if ("xml".equals(prefix)) return XMLConstants.XML_NS_URI;
            return XMLConstants.NULL_NS_URI;
        });When I evaluate using
        try {
          xPathExpression = xPath.compile(text);
        } catch (XPathExpressionException e) {
          e.printStackTrace();
        }where :
    text = "//property:xml-property";I get:
    I DON*T WANT THIS - MASTER
    But I need the CDATA for the Chart (I WANT THIS - CHART). I have then tried this expression:
    text = "//property:xml-property[property:name=\"Chart\"]";But it just gives an empty result. Any ideas on how to write the correct xpath expression for this?

    This is returning the right data:
    tesxt = "//property:extended-item[@name=\"Chart\"]/property:xml-property";

  • Why XPath didnot work with Namespace ?

    Dear all,
    When I parsing a xml document with Namespace by XPath , it didnot work well , but if I remove the part of Namespace , it worked well , I am not sure if I processed with right steps , any help is appreciated :
    My parser : jdom-b9
    jdk : 1.4.1
    My code is like :
    import java.io.*;
    import java.util.*;
    import org.jdom.*;
    import org.jdom.input.*;
    import org.jdom.output.*;
    import org.jdom.xpath.*;
    public class XPathTest {   
        public static void main(String[] args) throws IOException, JDOMException {
            if (args.length != 1) {
                System.err.println("Usage: samples.XPathTest [test.xml]");
                return;
            String filename = args[0];
            PrintStream out = System.out;
            SAXBuilder builder = new SAXBuilder();
            Document doc = builder.build(new File(filename));
            Element root = doc.getRootElement();          
            XPath path = XPath.newInstance("//Worksheet");          
            path.addNamespace("ss","urn:schemas-microsoft-com:office:spreadsheet");
            // or use :
            //Namespace ns = root.getNamespace();
            //path.addNamespace(ns);
            List elementNames = path.selectNodes(doc);
            if (elementNames.size() == 0) {
                out.println("This xml contains no element <Worksheet>");
            } else {
                out.println("This xml contains " + elementNames.size() + " <Worksheet> :");
                Iterator i = elementNames.iterator();
                while (i.hasNext()) {
                    out.println("\t" + ((Element)i.next()).getName());
    }and test.xml :
    <?xml version="1.0"?>
    <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
    xmlns:html="http://www.w3.org/TR/REC-html40">
    <Worksheet ss:Name="Sheet2">
      <Table ss:ExpandedColumnCount="12" ss:ExpandedRowCount="38" x:FullColumns="1"
       x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="14.25">
       <Column ss:Width="63"/>
       <Column ss:Width="76.5"/>
       <Column ss:Width="103.5"/>
       <Column ss:Width="123"/>
       <Column ss:Width="136.5"/>
       <Column ss:Width="83.25"/>
       <Column ss:Width="39"/>
       <Column ss:Width="76.5"/>
       <Column ss:Width="103.5"/>
       <Column ss:Width="90"/>
       <Column ss:Width="76.5"/>
       <Column ss:Width="90"/>
       <Row>
        <Cell><Data ss:Type="String">PORT_CODE</Data></Cell>
        <Cell><Data ss:Type="String">EFFECT_DATE</Data></Cell>
        <Cell><Data ss:Type="String">END_DATE</Data></Cell>
        <Cell><Data ss:Type="String">ENCODE_SCHEME_PORT</Data></Cell>
        <Cell><Data ss:Type="String">PORT_NAME</Data></Cell>
        <Cell><Data ss:Type="String">COUNTRY_CODE</Data></Cell>
        <Cell><Data ss:Type="String">IS_RT</Data></Cell>
        <Cell><Data ss:Type="String">DATA_SOURCE</Data></Cell>
        <Cell><Data ss:Type="String">LAST_UPD_DATE</Data></Cell>
        <Cell><Data ss:Type="String">LAST_UPD_USER</Data></Cell>
        <Cell><Data ss:Type="String">BP_UPD_DATE</Data></Cell>
        <Cell><Data ss:Type="String">PROVINCE_CODE</Data></Cell>
       </Row>
      </Table>
    </Worksheet>
    </Workbook>test1.xml
    <?xml version="1.0"?>
    <Workbook>
    <Worksheet Name="Sheet2">
      <Table>
       <Column Width="63"/>
       <Column Width="76.5"/>
       <Column Width="103.5"/>
       <Column Width="123"/>
       <Column Width="136.5"/>
       <Column Width="83.25"/>
       <Column Width="39"/>
       <Column Width="76.5"/>
       <Column Width="103.5"/>
       <Column Width="90"/>
       <Column Width="76.5"/>
       <Column Width="90"/>
       <Row>
        <Cell><Data Type="String">PORT_CODE</Data></Cell>
        <Cell><Data Type="String">EFFECT_DATE</Data></Cell>
        <Cell><Data Type="String">END_DATE</Data></Cell>
        <Cell><Data Type="String">ENCODE_SCHEME_PORT</Data></Cell>
        <Cell><Data Type="String">PORT_NAME</Data></Cell>
        <Cell><Data Type="String">COUNTRY_CODE</Data></Cell>
        <Cell><Data Type="String">IS_RT</Data></Cell>
        <Cell><Data Type="String">DATA_SOURCE</Data></Cell>
        <Cell><Data Type="String">LAST_UPD_DATE</Data></Cell>
        <Cell><Data Type="String">LAST_UPD_USER</Data></Cell>
        <Cell><Data Type="String">BP_UPD_DATE</Data></Cell>
        <Cell><Data Type="String">PROVINCE_CODE</Data></Cell>
       </Row>
      </Table>
    </Worksheet>
    </Workbook>The output of test.xml is : This xml contains no element <Worksheet>
    The output of test1.xml with no namespace part is :
    This xml contains 1 <Worksheet> :
    Worksheet
    WHY ????????????????????????????

    I do not use jdom but I had similar problems. You can try "//:worksheet". The prefix for the default namespace might be "". it fixed my problem.
    wz

  • Can't deploy due to Namespace error in ADF lib

    Hi,
    When deploying I'm getting a Namespace not valid error. Because adf-faces-impl-1013.jar contains XML files with a not valid namespace: http://xmlns.oracle.com/adf/view/faces/agent/capabilities.
    Please find below the error message:
    GRAVE: jar:file:/D:/WebLogic103/user_projects/domains/My_Domain/lib/adf-faces-impl-1013.jar!/META-INF/agent/capabilities.xml: Parsing error, line 2, column 89:
    org.xml.sax.SAXParseException: Espace de noms non valide : http://xmlns.oracle.com/adf/view/faces/agent/capabilities
    at org.apache.myfaces.trinidadinternal.agent.parse.CapabilitiesDocumentParser.startElement(CapabilitiesDocumentParser.java:114)
    Have you got any idea to solve my problem? Either indicating a good namespace which actually I don't know, or configuring Weblogic to avoid this validation? Or something else...
    Environment: eclipse ganymede 3.4 , Oracle Enterprise Pack (OEPE), Weblogic 10.3, ADF faces
    Thank you for your help

    Hi,
    Actually the good library to use is: adf-richclient-impl-11.jar
    After removing the old one from my classpath no more errors.
    (thank you Maroun ;-)

  • Can't Parse XHTML with XPATH

    I can't seem to parse a simple XHTML 1.1 document with XPATH. In the code below, the string xmlDoesntWork is taken directly from http://www.w3.org/TR/2001/REC-xhtml11-20010531/conformance.html. However, XPATH can't find the <title> element unless I remove the DOCTYPE line & the xmlns attribute from the <html> element (the xmlWorks string). XPATH returns null for the <title> element in the first string, but correctly retrieves the title in the second string. I tried adding a namespace context argument, but that didn't make any difference.
    Can anyone see what I'm doing wrong?
    import java.io.StringReader;
    import javax.xml.namespace.NamespaceContext;
    import javax.xml.xpath.XPath;
    import javax.xml.xpath.XPathConstants;
    import javax.xml.xpath.XPathExpression;
    import javax.xml.xpath.XPathFactory;
    import org.w3c.dom.Node;
    import org.xml.sax.InputSource;
    public class Test
    public static void main(String[] unused)throws Exception
       final String path = "/html/head/title";
       final String xmlDoesntWork =
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
          "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">" +
          "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" >" +
          "<head>" +
          "<title>Virtual Library</title>" +
          "</head>" +
          "<body>" +
          "<p>Moved to <a href=\"http://vlib.org/\">vlib.org</a>.</p>" +
          "</body>" +
          "</html>";
       String title = getText(xmlDoesntWork, path, null);
       System.out.println("Title: " + title);  
       final String xmlWorks =
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
          "<html>" +
          "<head>" +
          "<title>Virtual Library</title>" +
          "</head>" +
          "<body>" +
          "<p>Moved to <a href=\"http://vlib.org/\">vlib.org</a>.</p>" +
          "</body>" +
          "</html>";
       title = getText(xmlWorks, path, null);
       System.out.println("Title: " + title);  
    private static String getText(String xml, String path, NamespaceContext context)
       throws Exception
       StringReader reader = new StringReader(xml);          // Get input source
       InputSource  source = new InputSource(reader);
       XPath xpath = XPathFactory.newInstance().newXPath();
       if (context != null)                                  // If there's a namespace context
          xpath.setNamespaceContext(context);                // Inform XPATH
       XPathExpression expression = xpath.compile(path);     
       Node node = (Node)expression.evaluate(source, XPathConstants.NODE);
       return node == null ? null : node.getTextContent();
    }

    I'm perplexed. I made the change you suggested (code below), and still get the same error. Did I miss something?
    import java.io.StringReader;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import javax.xml.namespace.NamespaceContext;
    import javax.xml.xpath.XPath;
    import javax.xml.xpath.XPathConstants;
    import javax.xml.xpath.XPathExpression;
    import javax.xml.xpath.XPathFactory;
    import org.w3c.dom.Node;
    import org.xml.sax.InputSource;
    public class Test implements NamespaceContext
    private static final HashMap<String,String> URI_MAP    ;
    private static final HashMap<String,String> PREFIX_MAP ;
    private static final String XHTML_PREFIX = "xhtml"                                     ;
    private static final String XHTML_URI    = "http://www.w3.org/1999/xhtml"              ;
    private static final String XSI_PREFIX   = "xsi"                                       ;
    private static final String XSI_URI      = "http://www.w3.org/2001/XMLSchema-instance" ;
    static
       URI_MAP = new HashMap<String,String>();
       URI_MAP.put(XSI_PREFIX  , XSI_URI  );
       URI_MAP.put(XHTML_PREFIX, XHTML_URI);
       PREFIX_MAP = new HashMap<String,String>();
       PREFIX_MAP.put(XSI_URI  , XSI_PREFIX  );
       PREFIX_MAP.put(XHTML_URI, XHTML_PREFIX);
    public static void main(String[] unused)throws Exception
       new Test().run();
    public void run()throws Exception
       final String path = "/xhtml:html/xhtml:head/xhtml:title";
       final String xmlDoesntWork =
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
          "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">" +
          "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" >" +
          "<head>" +
          "<title>Virtual Library</title>" +
          "</head>" +
          "<body>" +
          "<p>Moved to <a href=\"http://vlib.org/\">vlib.org</a>.</p>" +
          "</body>" +
          "</html>";
       String title = getText(xmlDoesntWork, path, this);
       System.out.println("Title: " + title);  
       final String xmlWorks =
          "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
          "<html>" +
          "<head>" +
          "<title>Virtual Library</title>" +
          "</head>" +
          "<body>" +
          "<p>Moved to <a href=\"http://vlib.org/\">vlib.org</a>.</p>" +
          "</body>" +
          "</html>";
       title = getText(xmlWorks, path, this);
       System.out.println("Title: " + title);  
    private static String getText(String xml, String path, NamespaceContext context)
       throws Exception
       StringReader reader = new StringReader(xml);          // Get input source
       InputSource  source = new InputSource(reader);
       XPath xpath = XPathFactory.newInstance().newXPath();
       if (context != null)                                  // If there's a namespace context
          xpath.setNamespaceContext(context);                // Inform XPATH
       XPathExpression expression = xpath.compile(path);     
       Node node = (Node)expression.evaluate(source, XPathConstants.NODE);
       return node == null ? null : node.getTextContent();
    * Determines the URI associated with a namespace prefix.
    * @param prefix The prefix.
    * @return The  URI.
    public String getNamespaceURI(String prefix)
       String URI = URI_MAP.get(prefix);
       return URI;
    * Determines the prefix associated with a namespace URI.
    * @param URI The URI.
    * @return The prefix.
    public String getPrefix(String URI)
       String prefix = PREFIX_MAP.get(URI);
       return prefix;
    * Retrieves prefixes associated with a namespace URI.
    * @param URI The URI.
    * @return An iterator to the collection of prefixes.
    public Iterator getPrefixes(String URI)
       ArrayList<String> list = new ArrayList<String>();
       list.add(getPrefix(URI));
       return list.iterator();
    }

  • Parsing XML string with XPath

    Hi,-
    I am trying to parse an XML string with xpath as follows but I am getting null for getresult.
    I am getting java.xml.xpath.xpathexpressionexception at line where
    getresult = xpathexpression.evaluate(isource); is executed.
    What should I do after
    xpathexpression = xPath.compile("a/b");in the below snippet?
    Thanks
    String xmlstring ="..."; // a valid XML string;
    Xpath xpath = XPathFactory.newInstance().newPath();
    xpathexpression = xPath.compile("a/b");
    // I guess the following line is not correct
    InputSource isource = new inputSource(new ByteArrayInputStream(xmlstring.getBytes())); right
    getresult = xpathexpression.evaluate(isource);My xml string is like:
    <a>
      <b>
         <result> valid some more tags here
         </result>
      </b>
      <c> 10
      </c>
    </a>Edited by: geoman on Dec 8, 2008 2:30 PM

    I've never used the version of evaluate that takes an InputSource. The difficulty with using it is that it does not save the DOM object. Each expression you evaluate will have to create the DOM object, use it once and then throw it away. I've yet to write a program that only needs one answer from an XML document. Usually, I use XPath to locate somewhere in a document and then read "nearby" content, add new content nearby, delete content, or move content. I'd suggest you may want to parse the XML stream and save the DOM Document.
    Second, all of the XPath expressions search from a "context node". I have not had good luck searching from the Document object, so I always get the root element first. I think the expression should work if you use the root as the context node. You will need one of the versions of evaluate that uses an Object as the parameter.

  • Error in XPath 2.0 expression

    Hi everybody,
    I am using XMLSPY to test a XPath expression:
    <xsl:value-of select="fn:tokenize('a b c', '\s')"></xsl:value-of>                                   
    But I get the error:
    "This file is not valid:
    Error in XPath 2.0 expression"
    Any ideas?
    Thanks, regards
    Mario

    http://help.sap.com/saphelp_nw04/helpdata/en/d6/e44fcf98baa24a9686a7643a33f26f/frameset.htm
    /people/prasadbabu.nemalikanti3/blog/2006/09/20/receiver-determination-based-on-the-payload-of-input-dataextended-xpathcontext-object
    /people/prasadbabu.nemalikanti3/blog/2006/03/30/xpath-functions-in-xslt-mapping
    Using substring in the XPATH expression for Receiver Determination

  • Xpath and xml data queries

    I've got the xml found at:
    http://www.bankofcanada.ca/rss/fx/noon/fx-noon-all.xml.
    The xml looks like this(this is the US only one, but all the format and syntax is the same for the fx-noon-all.xml file):
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="http://purl.org/rss/1.0/"
    xmlns:cb="http://centralbanks.org/cb/1.0/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.w3c.org/1999/02/22-rdf-syntax-ns#rdf.xsd">
    <channel rdf:about="http://www.bankofcanada.ca/fx/daily_noon.html">
    <title>BoC noon rate: U.S. dollar</title>
    <link>http://www.bankofcanada.ca/fx/daily_noon.html</link>
    <description>Current day's noon foreign exchange rates from the Bank of Canada. Published at about 12:15 ET.</description>
    <items>
    <rdf:Seq>
    <rdf:li rdf:resource="http://www.bankofcanada.ca/rss/fx/noon/iexe0101.xml" />
    </rdf:Seq>
    </items>
    <dc:language>en</dc:language>
    <dc:date>2008-07-07</dc:date>
    </channel>
    <item rdf:about="http://www.bankofcanada.ca/rss/fx/noon/iexe0101.xml">
    <title>CA: 0.9830 USD = 1 CAD 2008-07-07 Bank of Canada noon rate</title>
    <link>http://www.bankofcanada.ca/fx/daily_noon.html</link>
    <description>1 Canadian Dollar = 0.9830 USD (USD = U.S. dollar). These are the Bank of Canada's nominal noon exchange rates, published at about 12:15 ET each business day. These are neither buying nor selling rates, and should be used for reference purposes only.</description>
    <dc:language>en</dc:language>
    <dc:date>2008-07-07</dc:date>
    <dc:format>text/html</dc:format>
    <cb:country>CA</cb:country>
    <cb:baseCurrency>CAD</cb:baseCurrency>
    <cb:targetCurrency>USD</cb:targetCurrency>
    <cb:value frequency="business" decimals="4">0.9830</cb:value>
    <cb:rateType>noon</cb:rateType>
    <cb:application>statistics</cb:application>
    </item>
    </rdf:RDF>
    I've inserted the xml into the CFS_XML_TABLE which has a column for the date
    and an XMLType column which holds the xml.
    I am trying to extract exchange rate data using a query like this:
    select extractValue(xml_data, '/RDF/item/title/text()') as "NodeVal"
    from cfs_xml_table;
    I'm just trying to get something out of it right now, but eventually I need to be able to get <cb:value>, <cb:baseCurrency> and <cb:targetCurrency>. Right now I can't even get the data in the title node...
    For the project I'm working on I have to use the Bank of Canada Feed.
    Does anyone have any ideas on what to do here?
    Thanks a lot,
    Devon

    I've never used namespaces with XPath before, but I happened to stumble across a solution that works by supplying a value for EXTRACTVALUE's "namespace_string" parameter (the third one).
    select
    extractvalue(
    xmltype(
    '<?xml version="1.0" encoding="ISO-8859-1"?>
    <rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="http://purl.org/rss/1.0/"
    xmlns:cb="http://centralbanks.org/cb/1.0/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.w3c.org/1999/02/22-rdf-syntax-ns#rdf.xsd">
    <channel rdf:about="http://www.bankofcanada.ca/fx/daily_noon.html">
    <title>BoC noon rate: U.S. dollar</title>
    <link>http://www.bankofcanada.ca/fx/daily_noon.html</link>
    <description>Current day''s noon foreign exchange rates from the Bank of Canada. Published at about 12:15 ET.</description>
    <items>
    <rdf:Seq>
    <rdf:li rdf:resource="http://www.bankofcanada.ca/rss/fx/noon/iexe0101.xml" />
    </rdf:Seq>
    </items>
    <dc:language>en</dc:language>
    <dc:date>2008-07-07</dc:date>
    </channel>
    <item rdf:about="http://www.bankofcanada.ca/rss/fx/noon/iexe0101.xml">
    <title>CA: 0.9830 USD = 1 CAD 2008-07-07 Bank of Canada noon rate</title>
    <link>http://www.bankofcanada.ca/fx/daily_noon.html</link>
    <description>1 Canadian Dollar = 0.9830 USD (USD = U.S. dollar). These are the Bank of Canada''s nominal noon exchange rates, published at about 12:15 ET each business day. These are neither buying nor selling rates, and should be used for reference purposes only.</description>
    <dc:language>en</dc:language>
    <dc:date>2008-07-07</dc:date>
    <dc:format>text/html</dc:format>
    <cb:country>CA</cb:country>
    <cb:baseCurrency>CAD</cb:baseCurrency>
    <cb:targetCurrency>USD</cb:targetCurrency>
    <cb:value frequency="business" decimals="4">0.9830</cb:value>
    <cb:rateType>noon</cb:rateType>
    <cb:application>statistics</cb:application>
    </item>
    </rdf:RDF>
    , '/rdf:RDF/item/title/text()'
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="http://purl.org/rss/1.0/"
    xmlns:cb="http://centralbanks.org/cb/1.0/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
    ) as result
    from dual ;
    RESULT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
    CA: 0.9830 USD = 1 CAD 2008-07-07 Bank of Canada noon rate        --
    Joe

  • Namespace addition in a DTD in ESR

    Hi,
    I have imported an external definition, a DTD, in my ESR. In external definition window in ESR there is a tab WSDL where I cant see namespace for he schema.
    Can someone help me with how to get namespace in that WSDL or how to declare and add a namespace in a DTD (doctype) structure?
    PFB the my DTD structure where MyMessage is root node in message structure.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE MyMessage SYSTEM "http://host.com/app_docs/dtd/PO/xyz.dtd" [
    <!--
                $Source: /abc/def/xyz.dtd,v $
                $Revision: 1.2 $
                $Date: 2012/06/27 09:12:17 $
                Version 2.5: everything in version 2.4 plus custom field amount totals
    -->
    <!ELEMENT abc (#PCDATA)>
    <!ELEMENT xyz (#PCDATA)>
    <!ATTLIST …….
    >
    ]>
    and PFB corresponding WSDL:
    <wsdl:definitions xmlns:wsdl="………/wsdl/">
       <wsdl:types>
          <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> ------> I want targetNamesapce field here with valid namespace.
             <xsd:element name="MyMessage" type="MyMessage" />
             <xsd:complexType ……………………….>
                <xsd:sequence>
                   <xsd:element name="………………" type="xsd:string" />
                   <xsd:element name="………………" type="xsd:string" />

    Its very large and complex DTD which I imported, it looked like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE PurchaseOrderMessage SYSTEM "http://host.com/app_docs/dtd/po/PO.dtd" [
    <!ELEMENT Address (#PCDATA)>
    <!ATTLIST Address
        linenumber CDATA #REQUIRED
        label CDATA #IMPLIED
    >
    ]>

  • Namespace /CRYSTAL/ missing

    hello,
    I'm trying to install the crystal reports 2008 but when importing the requests the system says that
    there is a problem with the namespace /CRYSTAL/
    This namespace doesn't exist in my system (abap netweaver trial).
    any idea on how to create this ?
    regards

    hello ingo,
      thanks for the reply but, the error occurs when trying to import the requests
      when the import off the 1st request is running I can see some data objects being created
      but they have status "new" and the import keeps on running
      when I try to activate them myself, he gives an error on the namespace "/crystal/"
    Table /CRYSTAL/AUTHCHK could not be activated                                  
    (E- Table name /CRYSTAL/AUTHCHK does not lie in valid namespace )              
    any idea's on how to solve this ?
                                                                                    regards,

Maybe you are looking for

  • Save for Web: line artifact at right edge

    I've searched the forums and the Web for this one, but I can't find any answer. I'm currently in CS5, but I believe this was happening in CS4 and maybe earlier. When in the Save for Web dialogue (it doesn't matter what format I'm saving to or if tran

  • What is use of T.code

    hii What is the use T.COde MEAN in SAP MM ans SRM?? What purpose we have this transaction code in system.. Can somebody explain me in depth detail about the same .. Thanks

  • Playbook freezes up when viewing email, FB messages...

    I'm having an issue with freezing while viewing messages. The screen will either totally freeze or will scroll madly up or down.

  • Cant accept ics invitations

    Hello, I know this question has been asked many times - but I wan't to post this again and see if I have missed something. I am so frustrated with not being able to accept meeting invites from Outlook users when they send me a meeting invite as a .ic

  • If I turn off notifications/data to take a nap, will I miss some alerts?

    I sometimes want to turn off all sounds on my iPhone except for the phone ringer when I take a nap, so I can sleep undisturbed unless someone needs to reach me by phone. My question is: If I turn off all notifications in the settings, temporarily, wi