How standardized is the "@" notation in XPath?

Discussion in 'XML' started by Cambridge Ray, Aug 2, 2011.

  1. I have several GUI XML utilities (Stylus $tudio, BaseX61) which deal
    nicely with the "@" notation for attributes. However, when I tried to
    use it with the Xerces-C library, it crashed.

    TIA,

    -RFH
     
    Cambridge Ray, Aug 2, 2011
    #1
    1. Advertising

  2. Cambridge Ray wrote:
    > I have several GUI XML utilities (Stylus $tudio, BaseX61) which deal
    > nicely with the "@" notation for attributes. However, when I tried to
    > use it with the Xerces-C library, it crashed.


    XPath 1.0 defines the attribute axis and @ as a shortcut to use it, see
    http://www.w3.org/TR/xpath/#path-abbrev

    Does Xerces implement XPath? Isn't that Xalan's job in the toolset of
    XML tools Apache provides? Or are you using some xpath in a schema?

    --

    Martin Honnen --- MVP Data Platform Development
    http://msmvps.com/blogs/martin_honnen/
     
    Martin Honnen, Aug 2, 2011
    #2
    1. Advertising

  3. On 8/2/2011 12:54 PM, Martin Honnen wrote:
    > XPath 1.0 defines the attribute axis and @ as a shortcut to use it, see
    > http://www.w3.org/TR/xpath/#path-abbrev
    >
    > Does Xerces implement XPath? Isn't that Xalan's job in the toolset of
    > XML tools Apache provides? Or are you using some xpath in a schema?


    Yes, and that's correct, and what is the querant actually trying to do?
    It's more likely that you're misusing something than that you've found a
    bug in the Apache tools, but bugs are certainly possible.


    --
    Joe Kesselman,
    http://www.love-song-productions.com/people/keshlam/index.html

    {} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
    /\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
     
    Joe Kesselman, Aug 3, 2011
    #3
  4. On Aug 2, 11:54 am, Martin Honnen <> wrote:
    > Cambridge Ray wrote:
    > > I have several GUI XML utilities (Stylus $tudio, BaseX61) which deal
    > > nicely with the "@" notation for attributes. However, when I tried to
    > > use it with the Xerces-C library, it crashed.

    >
    > XPath 1.0 defines the attribute axis and @ as a shortcut to use it, seehttp://www.w3.org/TR/xpath/#path-abbrev
    >


    > Does Xerces implement XPath?


    Yes, it does. I was provided the code below by one of Xerces' authors,
    Alberto Massari.

    -Ramon

    ---------------------
    #include <xercesc/parsers/XercesDOMParser.hpp>
    #include <iostream>

    using namespace std;

    main(int argc, char *argv[])
    {

    try {
    XMLPlatformUtils::Initialize();
    }
    catch (const XMLException& toCatch) {
    char *pMessage = XMLString::transcode(toCatch.getMessage());
    fprintf(stderr, "Error during initialization! \n %s \n",
    pMessage);
    XMLString::release(&pMessage);
    return -1;
    }
    XercesDOMParser parser;
    parser.parse("simple-sample.xml");
    DOMDocument *document = parser.getDocument();
    XMLCh xpathStr[100];

    XMLString::transcode("/line-segments/horizontal/distance",
    xpathStr, sizeof(xpathStr) - 1);

    DOMXPathResult* result = (DOMXPathResult*)document->evaluate
    (xpathStr,
    (const xercesc_3_1::DOMNode*)document->getDocumentElement(),
    NULL,
    DOMXPathResult::ORDERED_NODE_SNAPSHOT_TYPE,
    NULL);

    int count = result->getSnapshotLength();
    for (int i = 0; i < count; i++) {
    result->snapshotItem(i); // this selects the node for the
    getNodeValue call
    DOMNode* item = result->getNodeValue();
    cout << "item #" << i+1 << ": `" << XMLString::transcode(item-
    >getTextContent()) << "'" << endl;

    // do something with the item->getTextContent()
    }
    result->release();
    return 0;
    }
     
    Cambridge Ray, Aug 10, 2011
    #4
  5. On Aug 10, 3:03 pm, Cambridge Ray <> wrote:
    > On Aug 2, 11:54 am, Martin Honnen <> wrote:
    >
    > > Cambridge Ray wrote:
    > > > I have several GUI XML utilities (Stylus $tudio, BaseX61) which deal
    > > > nicely with the "@" notation for attributes. However, when I tried to
    > > > use it with the Xerces-C library, it crashed.

    >
    > > XPath 1.0 defines the attribute axis and @ as a shortcut to use it, seehttp://www.w3.org/TR/xpath/#path-abbrev

    >


    >> Does Xerces implement XPath?

    >
    > Yes, it does.


    Ooops, I guess XPath is more complex than a simple slash-separated set
    of elements.

    Correction: Xerces provides a minimum XPath implementation, through
    the document->evaluate() member function. I guess that answers the
    question in the OP.

    -Ramon
     
    Cambridge Ray, Aug 10, 2011
    #5
  6. On 8/10/2011 4:13 PM, Cambridge Ray wrote:
    > Ooops, I guess XPath is more complex than a simple slash-separated set
    > of elements.


    Yes, it is.

    A complete XPath 1.0 implementation that works with Xerces is available
    from Apache, as part of the Xalan package (which also supports the XSLT
    transformation/stylesheet language, which uses XPath).

    --
    Joe Kesselman,
    http://www.love-song-productions.com/people/keshlam/index.html

    {} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
    /\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
     
    Joe Kesselman, Aug 10, 2011
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DeMarcus

    Is 'if' standardized?

    DeMarcus, Jun 16, 2005, in forum: Java
    Replies:
    4
    Views:
    383
    DeMarcus
    Jun 16, 2005
  2. Mike Treseler

    standardized interfaces

    Mike Treseler, Nov 6, 2006, in forum: VHDL
    Replies:
    0
    Views:
    418
    Mike Treseler
    Nov 6, 2006
  3. Grey Squirrel

    Hungarian Notation Vs. Pascal Notation?

    Grey Squirrel, Mar 19, 2007, in forum: ASP .Net
    Replies:
    6
    Views:
    1,364
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Mar 21, 2007
  4. Tameem
    Replies:
    454
    Views:
    12,498
  5. Robert Mark Bram

    Dot notation V Bracket notation

    Robert Mark Bram, Jul 4, 2003, in forum: Javascript
    Replies:
    3
    Views:
    484
    Robert Mark Bram
    Jul 5, 2003
Loading...

Share This Page