Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How standardized is the "@" notation in XPath?

Reply
Thread Tools

How standardized is the "@" notation in XPath?

 
 
Cambridge Ray
Guest
Posts: n/a
 
      08-02-2011
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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      08-02-2011
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/
 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      08-03-2011
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...lam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
 
Reply With Quote
 
Cambridge Ray
Guest
Posts: n/a
 
      08-10-2011
On Aug 2, 11:54*am, Martin Honnen <mahotr...@yahoo.de> 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:OMNode*)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;
}


 
Reply With Quote
 
Cambridge Ray
Guest
Posts: n/a
 
      08-10-2011
On Aug 10, 3:03*pm, Cambridge Ray <gopos...@jonjay.com> wrote:
> On Aug 2, 11:54*am, Martin Honnen <mahotr...@yahoo.de> 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
 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      08-10-2011
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...lam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to convert Infix notation to postfix notation Tameem C Programming 441 11-30-2009 08:07 AM
Hungarian Notation Vs. Pascal Notation? Grey Squirrel ASP .Net 6 03-21-2007 09:42 AM
Is 'if' standardized? DeMarcus Java 4 06-16-2005 04:48 PM
Dot notation V Bracket notation Robert Mark Bram Javascript 3 07-05-2003 03:59 AM



Advertisments