From: Keith B. <KSB...@lb...> - 2003-10-15 19:03:27
|
Hello, Wonderfull little tool this is, though I've a questions about c14n and xpath. I'm trying to work through the example of exclusinve c14n from the exc-xmlc14n spec and xml doesn't seem to like the xpath expression. Specifically: $ cat doc1.xml <n0:pdu xmlns:n0='http://a.example.com'> <n1:elem1 xmlns:n1='http://b.example'> content </n1:elem1> </n0:pdu> $ xml c14n --without-comments doc1.xml '(//. | //@* | //namespace::*)[ancestor-or-self::n1:elem1]' warning: failed to load external entity "(//.%20%7C%20//@*%20%7C%20//namespace%3A%3A*)%5Bancestor-or-self%3A%3An1%3Aelem1%5D" Error: unable to parse file "(//. | //@* | //namespace::*)[ancestor-or-self::n1:elem1]" Error: unable to evaluate xpath expression Am I doing something wrong here? Thanks, ksb |
From: Mikhail G. <mgr...@co...> - 2003-10-15 20:43:34
|
create a file called 'doc1.xpath' and put the following in there <?xml version="1.0"?> <XPath xmlns:n0="http://a.example.com" xmlns:n1="http://b.example"> (//. | //@* | //namespace::*)[ancestor-or-self::n1:elem1] </XPath> Your command will be the following xml c14n --exc-without-comments doc1.xml doc1.xpath which gives output <n1:elem1 xmlns:n1="http://b.example"> content </n1:elem1> Thanks for noticing this as it was totally undocumented. --Mikhail ----- Original Message ----- From: "Keith Beattie" <KSB...@lb...> To: <xml...@li...> Sent: Wednesday, October 15, 2003 3:03 PM Subject: [Xmlstar-devel] c14n xpath > Hello, > > Wonderfull little tool this is, though I've a questions about c14n and > xpath. > > I'm trying to work through the example of exclusinve c14n from the > exc-xmlc14n spec and xml doesn't seem to like the xpath expression. > Specifically: > > $ cat doc1.xml > <n0:pdu xmlns:n0='http://a.example.com'> > <n1:elem1 xmlns:n1='http://b.example'> > content > </n1:elem1> > </n0:pdu> > > $ xml c14n --without-comments doc1.xml '(//. | //@* | > //namespace::*)[ancestor-or-self::n1:elem1]' > warning: failed to load external entity > "(//.%20%7C%20//@*%20%7C%20//namespace%3A%3A*)%5Bancestor-or-self%3A%3An1%3A elem1%5D" > Error: unable to parse file "(//. | //@* | > //namespace::*)[ancestor-or-self::n1:elem1]" > Error: unable to evaluate xpath expression > > Am I doing something wrong here? > > Thanks, > ksb > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > SourceForge.net hosts over 70,000 Open Source Projects. > See the people who have HELPED US provide better services: > Click here: http://sourceforge.net/supporters.php > _______________________________________________ > xmlstar-devel mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlstar-devel --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.524 / Virus Database: 321 - Release Date: 10/6/2003 |
From: Keith B. <KSB...@lb...> - 2003-10-17 01:39:54
|
Thank you very much! I realize that this is somewhat off-topic but I'm suprised at the need for the namespace declarations in the XPath element. The same info is in the xml doc... Is this repetition something required by xpath or is an artifact of xmlstar's or libxml's API? Any recommendations on good xpath docs, appreciated. Thanks, ksb Mikhail Grushinskiy wrote: > create a file called 'doc1.xpath' > > and put the following in there > > <?xml version="1.0"?> > <XPath xmlns:n0="http://a.example.com" xmlns:n1="http://b.example"> > (//. | //@* | //namespace::*)[ancestor-or-self::n1:elem1] > </XPath> > > Your command will be the following > > xml c14n --exc-without-comments doc1.xml doc1.xpath > > which gives output > > <n1:elem1 xmlns:n1="http://b.example"> > content > </n1:elem1> > > Thanks for noticing this as it was totally undocumented. > > --Mikhail > > ----- Original Message ----- > From: "Keith Beattie" <KSB...@lb...> > To: <xml...@li...> > Sent: Wednesday, October 15, 2003 3:03 PM > Subject: [Xmlstar-devel] c14n xpath > > > >>Hello, >> >>Wonderfull little tool this is, though I've a questions about c14n and >>xpath. >> >>I'm trying to work through the example of exclusinve c14n from the >>exc-xmlc14n spec and xml doesn't seem to like the xpath expression. >>Specifically: >> >>$ cat doc1.xml >><n0:pdu xmlns:n0='http://a.example.com'> >> <n1:elem1 xmlns:n1='http://b.example'> >> content >> </n1:elem1> >></n0:pdu> >> >>$ xml c14n --without-comments doc1.xml '(//. | //@* | >>//namespace::*)[ancestor-or-self::n1:elem1]' >>warning: failed to load external entity >> > > "(//.%20%7C%20//@*%20%7C%20//namespace%3A%3A*)%5Bancestor-or-self%3A%3An1%3A > elem1%5D" > >>Error: unable to parse file "(//. | //@* | >>//namespace::*)[ancestor-or-self::n1:elem1]" >>Error: unable to evaluate xpath expression >> >>Am I doing something wrong here? >> >>Thanks, >>ksb >> >> >> >>------------------------------------------------------- >>This SF.net email is sponsored by: SF.net Giveback Program. >>SourceForge.net hosts over 70,000 Open Source Projects. >>See the people who have HELPED US provide better services: >>Click here: http://sourceforge.net/supporters.php >>_______________________________________________ >>xmlstar-devel mailing list >>xml...@li... >>https://lists.sourceforge.net/lists/listinfo/xmlstar-devel > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.524 / Virus Database: 321 - Release Date: 10/6/2003 > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > SourceForge.net hosts over 70,000 Open Source Projects. > See the people who have HELPED US provide better services: > Click here: http://sourceforge.net/supporters.php > _______________________________________________ > xmlstar-devel mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlstar-devel |
From: Shaun M. <sh...@gn...> - 2003-10-17 02:57:19
|
The XPath expression isn't part of the XML document, so the namespace declarations in the XML document are irrelevant to the XPath expression. The prefix-namespace association has to be given to the XPath processor for a namespace prefix in an XPath to mean anything. You might wonder why an XPath processor can't just look at the prefixes used in the XML file and use the same ones. Here's an example: <foo:foo xmlns:foo="http://example.com/foo"> <foo:bar/> <foo:bar xmlns:foo="http://example.com/foobar"/> </foo:foo> What would the XPath expression //foo:bar select? -- Shaun On Thu, 2003-10-16 at 20:39, Keith Beattie wrote: > Thank you very much! > > I realize that this is somewhat off-topic but I'm suprised at the need > for the namespace declarations in the XPath element. The same info is > in the xml doc... Is this repetition something required by xpath or is > an artifact of xmlstar's or libxml's API? > > Any recommendations on good xpath docs, appreciated. > > Thanks, > ksb > > Mikhail Grushinskiy wrote: > > create a file called 'doc1.xpath' > > > > and put the following in there > > > > <?xml version="1.0"?> > > <XPath xmlns:n0="http://a.example.com" xmlns:n1="http://b.example"> > > (//. | //@* | //namespace::*)[ancestor-or-self::n1:elem1] > > </XPath> > > > > Your command will be the following > > > > xml c14n --exc-without-comments doc1.xml doc1.xpath > > > > which gives output > > > > <n1:elem1 xmlns:n1="http://b.example"> > > content > > </n1:elem1> > > > > Thanks for noticing this as it was totally undocumented. > > > > --Mikhail > > > > ----- Original Message ----- > > From: "Keith Beattie" <KSB...@lb...> > > To: <xml...@li...> > > Sent: Wednesday, October 15, 2003 3:03 PM > > Subject: [Xmlstar-devel] c14n xpath > > > > > > > >>Hello, > >> > >>Wonderfull little tool this is, though I've a questions about c14n and > >>xpath. > >> > >>I'm trying to work through the example of exclusinve c14n from the > >>exc-xmlc14n spec and xml doesn't seem to like the xpath expression. > >>Specifically: > >> > >>$ cat doc1.xml > >><n0:pdu xmlns:n0='http://a.example.com'> > >> <n1:elem1 xmlns:n1='http://b.example'> > >> content > >> </n1:elem1> > >></n0:pdu> > >> > >>$ xml c14n --without-comments doc1.xml '(//. | //@* | > >>//namespace::*)[ancestor-or-self::n1:elem1]' > >>warning: failed to load external entity > >> > > > > "(//.%20%7C%20//@*%20%7C%20//namespace%3A%3A*)%5Bancestor-or-self%3A%3An1%3A > > elem1%5D" > > > >>Error: unable to parse file "(//. | //@* | > >>//namespace::*)[ancestor-or-self::n1:elem1]" > >>Error: unable to evaluate xpath expression > >> > >>Am I doing something wrong here? > >> > >>Thanks, > >>ksb > >> > >> > >> > >>------------------------------------------------------- > >>This SF.net email is sponsored by: SF.net Giveback Program. > >>SourceForge.net hosts over 70,000 Open Source Projects. > >>See the people who have HELPED US provide better services: > >>Click here: http://sourceforge.net/supporters.php > >>_______________________________________________ > >>xmlstar-devel mailing list > >>xml...@li... > >>https://lists.sourceforge.net/lists/listinfo/xmlstar-devel > > > > > > > > --- > > Outgoing mail is certified Virus Free. > > Checked by AVG anti-virus system (http://www.grisoft.com). > > Version: 6.0.524 / Virus Database: 321 - Release Date: 10/6/2003 > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: SF.net Giveback Program. > > SourceForge.net hosts over 70,000 Open Source Projects. > > See the people who have HELPED US provide better services: > > Click here: http://sourceforge.net/supporters.php > > _______________________________________________ > > xmlstar-devel mailing list > > xml...@li... > > https://lists.sourceforge.net/lists/listinfo/xmlstar-devel > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > SourceForge.net hosts over 70,000 Open Source Projects. > See the people who have HELPED US provide better services: > Click here: http://sourceforge.net/supporters.php > _______________________________________________ > xmlstar-devel mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlstar-devel |
From: Keith B. <KSB...@lb...> - 2003-10-17 09:17:51
|
Well, I'm having trouble finding an introductory reference on xpath that includes namespaces (I generally try to avoid starting with the spec but it appears I don't have much of a choice here). But in the meantime... Shaun McCance wrote: > The XPath expression isn't part of the XML document, so the namespace > declarations in the XML document are irrelevant to the XPath expression. > The prefix-namespace association has to be given to the XPath processor > for a namespace prefix in an XPath to mean anything. Seems to me that the same be said about any element or attribute name. > You might wonder why an XPath processor can't just look at the prefixes > used in the XML file and use the same ones. *Exactly* what I'm wondering! > Here's an example: > > <foo:foo xmlns:foo="http://example.com/foo"> > <foo:bar/> > <foo:bar xmlns:foo="http://example.com/foobar"/> > </foo:foo> > > What would the XPath expression //foo:bar select? I guess I'd expect both foo:bar elements: <foo:bar/> <foo:bar xmlns:foo="http://example.com/foobar"/> Which means that I'm assuming the absence of a namespace specification means 'any namespace'. Bad assumption on my part apparently... :) So is it possible to provide these prefix-namespace associations in the xpath expression itself? And not pass it in via (what appears to be the out-of-band method of) the XPath element? For example, rather than: <XPath xmlns:foo="http://example.com/foo"> //foo:bar </XPath> something like: <XPath> //foo:bar[ns::xmlns:foo="http://example.com/foo"> </XPath> even though I know that's not the proper syntax. (I ask because I'm working with another xpath implementation (in python) and using xmlstar as a reference.) Thanks so much for your time. ksb |
From: Mikhail G. <mgr...@co...> - 2003-10-17 14:33:26
|
There is no such thing as defining namespace in XPath expression itself. There are some XPath functions local-name(), name() which can help you to work with prefixes, but the truth is: namespace is identified by its URI portion, that is why you have to define bindings prefix-URI for XPath. ----- Original Message ----- From: "Keith Beattie" <KSB...@lb...> To: "Shaun McCance" <sh...@gn...> Cc: <xml...@li...> Sent: Friday, October 17, 2003 5:09 AM Subject: Re: [Xmlstar-devel] c14n xpath > Well, I'm having trouble finding an introductory reference on xpath that > includes namespaces (I generally try to avoid starting with the spec but > it appears I don't have much of a choice here). But in the meantime... > > Shaun McCance wrote: > > The XPath expression isn't part of the XML document, so the namespace > > declarations in the XML document are irrelevant to the XPath expression. > > The prefix-namespace association has to be given to the XPath processor > > for a namespace prefix in an XPath to mean anything. > > Seems to me that the same be said about any element or attribute name. > > > You might wonder why an XPath processor can't just look at the prefixes > > used in the XML file and use the same ones. > > *Exactly* what I'm wondering! > > > Here's an example: > > > > <foo:foo xmlns:foo="http://example.com/foo"> > > <foo:bar/> > > <foo:bar xmlns:foo="http://example.com/foobar"/> > > </foo:foo> > > > > What would the XPath expression //foo:bar select? > > I guess I'd expect both foo:bar elements: > > <foo:bar/> > <foo:bar xmlns:foo="http://example.com/foobar"/> > > Which means that I'm assuming the absence of a namespace specification > means 'any namespace'. Bad assumption on my part apparently... :) > > So is it possible to provide these prefix-namespace associations in the > xpath expression itself? And not pass it in via (what appears to be the > out-of-band method of) the XPath element? For example, rather than: > > <XPath xmlns:foo="http://example.com/foo"> > //foo:bar > </XPath> > > something like: > > <XPath> > //foo:bar[ns::xmlns:foo="http://example.com/foo"> > </XPath> > > even though I know that's not the proper syntax. (I ask because I'm > working with another xpath implementation (in python) and using xmlstar > as a reference.) > > Thanks so much for your time. > ksb > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > SourceForge.net hosts over 70,000 Open Source Projects. > See the people who have HELPED US provide better services: > Click here: http://sourceforge.net/supporters.php > _______________________________________________ > xmlstar-devel mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlstar-devel --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.525 / Virus Database: 322 - Release Date: 10/9/2003 |