|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
NamespacesHi,
If I have the following XML: <ib type="set" from="vas" id="2301181" to="DEV_LG" xmlns="http://www.vettro.com/1/ib.xsd"> <service username="leegardner"> <vas:update xmlns:vas="http://www.vettro.com/1/vas.xsd"> <vas:field name="serial">ABC</vas:field> </vas:object> </vas:update> </service> </ib> Would the following XPath extract the text node holding ABC: /service/vas:update/vas:object/vas:field[@name='serial']/text() Assuming the namespaces were declared: vas -> http://www.vettro.com/1/ib.xsd Code sample: xpf = XPathFactory.newInstance(); xpath = xpf.newXPath(); xpath.setNamespaceContext(new MyNamespaceContext()); XPathExpression e = xpath.compile(expression); Object o = e.evaluate(target, XPathConstants.NODESET); protected class MyNamespaceContext implements NamespaceContext { private Map namespaceMap = new HashMap(); public void addNamespace(String prefix, String url) { namespaceMap.put(prefix, url); } public void addNamespaces(Map map) { namespaceMap.putAll(map); } public String getNamespaceURI(String prefix) { String s = (String)namespaceMap.get(prefix); if (s == null) s = ""; return s; } public String getPrefix(String uri) { return null; } public Iterator getPrefixes(String namespaceURI) { return null; } } (Interestingly, Saxon never calls the namespace context implementation.) Thanks, John ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
|
|
Re: NamespacesSaxon searches the children of the document node for an element named
service, in the null namespace, finds that the only child of the document node is an element called ib, in namespace http://www.vettro.com/1/ib.xsd, and exits. But I would expect it to call your NamespaceContext implementation anyway, because it resolves all names in path expressions at compile time, before it knows that the first step in the path expression will select nothing. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: saxon-help-bounces@... > [mailto:saxon-help-bounces@...] On Behalf > Of John Baker > Sent: 09 August 2008 18:38 > To: Mailing list for the SAXON XSLT and XQuery processor > Subject: [saxon] Namespaces > > Hi, > > If I have the following XML: > > <ib type="set" from="vas" id="2301181" to="DEV_LG" > xmlns="http://www.vettro.com/1/ib.xsd"> > <service username="leegardner"> > <vas:update xmlns:vas="http://www.vettro.com/1/vas.xsd"> > <vas:field name="serial">ABC</vas:field> > </vas:object> > </vas:update> > </service> > </ib> > > Would the following XPath extract the text node holding ABC: > > /service/vas:update/vas:object/vas:field[@name='serial']/text() > > Assuming the namespaces were declared: > > vas -> http://www.vettro.com/1/ib.xsd > > Code sample: > > xpf = XPathFactory.newInstance(); > xpath = xpf.newXPath(); > xpath.setNamespaceContext(new MyNamespaceContext()); > XPathExpression e = xpath.compile(expression); > Object o = e.evaluate(target, XPathConstants.NODESET); > > protected class MyNamespaceContext implements NamespaceContext > { > private Map namespaceMap = new HashMap(); > > public void addNamespace(String prefix, String url) > { namespaceMap.put(prefix, url); } > > public void addNamespaces(Map map) > { namespaceMap.putAll(map); } > > public String getNamespaceURI(String prefix) > { > String s = (String)namespaceMap.get(prefix); > if (s == null) s = ""; > return s; > } > > public String getPrefix(String uri) > { return null; } > > public Iterator getPrefixes(String namespaceURI) > { return null; } > } > > (Interestingly, Saxon never calls the namespace context > implementation.) > > > > Thanks, > > > John > > > > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge Build the coolest Linux based > applications with Moblin SDK & win great prizes Grand prize > is a trip for two to an Open Source event anywhere in the > world http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > saxon-help mailing list archived at > http://saxon.markmail.org/ saxon-help@... > https://lists.sourceforge.net/lists/listinfo/saxon-help ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
|
|
Re: NamespacesArgh, school boy error!
On Saturday 09 August 2008 19:19:07 you wrote: > Saxon searches the children of the document node for an element named > service, in the null namespace, finds that the only child of the document > node is an element called ib, in namespace http://www.vettro.com/1/ib.xsd, > and exits. > > But I would expect it to call your NamespaceContext implementation anyway, > because it resolves all names in path expressions at compile time, before > it knows that the first step in the path expression will select nothing. > > Michael Kay > http://www.saxonica.com/ > > > -----Original Message----- > > From: saxon-help-bounces@... > > [mailto:saxon-help-bounces@...] On Behalf > > Of John Baker > > Sent: 09 August 2008 18:38 > > To: Mailing list for the SAXON XSLT and XQuery processor > > Subject: [saxon] Namespaces > > > > Hi, > > > > If I have the following XML: > > > > <ib type="set" from="vas" id="2301181" to="DEV_LG" > > xmlns="http://www.vettro.com/1/ib.xsd"> > > <service username="leegardner"> > > <vas:update xmlns:vas="http://www.vettro.com/1/vas.xsd"> > > <vas:field name="serial">ABC</vas:field> > > </vas:object> > > </vas:update> > > </service> > > </ib> > > > > Would the following XPath extract the text node holding ABC: > > > > /service/vas:update/vas:object/vas:field[@name='serial']/text() > > > > Assuming the namespaces were declared: > > > > vas -> http://www.vettro.com/1/ib.xsd > > > > Code sample: > > > > xpf = XPathFactory.newInstance(); > > xpath = xpf.newXPath(); > > xpath.setNamespaceContext(new MyNamespaceContext()); > > XPathExpression e = xpath.compile(expression); > > Object o = e.evaluate(target, XPathConstants.NODESET); > > > > protected class MyNamespaceContext implements NamespaceContext > > { > > private Map namespaceMap = new HashMap(); > > > > public void addNamespace(String prefix, String url) > > { namespaceMap.put(prefix, url); } > > > > public void addNamespaces(Map map) > > { namespaceMap.putAll(map); } > > > > public String getNamespaceURI(String prefix) > > { > > String s = (String)namespaceMap.get(prefix); > > if (s == null) s = ""; > > return s; > > } > > > > public String getPrefix(String uri) > > { return null; } > > > > public Iterator getPrefixes(String namespaceURI) > > { return null; } > > } > > > > (Interestingly, Saxon never calls the namespace context > > implementation.) > > > > > > > > Thanks, > > > > > > John > > > > > > > > -------------------------------------------------------------- > > ----------- > > This SF.Net email is sponsored by the Moblin Your Move > > Developer's challenge Build the coolest Linux based > > applications with Moblin SDK & win great prizes Grand prize > > is a trip for two to an Open Source event anywhere in the > > world http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > saxon-help mailing list archived at > > http://saxon.markmail.org/ saxon-help@... > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge Build the coolest Linux based applications with Moblin SDK & win > great prizes Grand prize is a trip for two to an Open Source event anywhere > in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > saxon-help@... > https://lists.sourceforge.net/lists/listinfo/saxon-help ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
|
|
Re: NamespacesJohn,
To add a third mistake to the two Mike mentioned: John Baker wrote: > Assuming the namespaces were declared: > > vas -> http://www.vettro.com/1/ib.xsd > > That isn't consistent with the name space in the document (which maps vas to ...vas.xsd, not ...ib.xsd). It doesn't have to be of course, but it probably isn't what you meant. Trevor Nash -- Melvaig Technologies Limited voice: +44 (0) 1445 771363 email: tcn@... web: http://www.melvaig.co.uk Registered in Scotland No 194737 5 Melvaig, Gairloch, Ross-shire IV21 2EA ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
|
|
Re: NamespacesMike,
How do I set the default namespace to be http://www.vettro.com/1/ib.xsd, or perhaps I should be asking, is this correct: /ib/service/vas:update/vas:object/vas:field[@name='serial']/text() You've said ib is in the NS http://www.vettro.com/1/ib.xsd, so how do I tell the parser? Perhaps the getNamespaceURI function should return the NS for empty string? John On Saturday 09 August 2008 19:19:07 you wrote: > Saxon searches the children of the document node for an element named > service, in the null namespace, finds that the only child of the document > node is an element called ib, in namespace http://www.vettro.com/1/ib.xsd, > and exits. > > But I would expect it to call your NamespaceContext implementation anyway, > because it resolves all names in path expressions at compile time, before > it knows that the first step in the path expression will select nothing. > > Michael Kay > http://www.saxonica.com/ > > > -----Original Message----- > > From: saxon-help-bounces@... > > [mailto:saxon-help-bounces@...] On Behalf > > Of John Baker > > Sent: 09 August 2008 18:38 > > To: Mailing list for the SAXON XSLT and XQuery processor > > Subject: [saxon] Namespaces > > > > Hi, > > > > If I have the following XML: > > > > <ib type="set" from="vas" id="2301181" to="DEV_LG" > > xmlns="http://www.vettro.com/1/ib.xsd"> > > <service username="leegardner"> > > <vas:update xmlns:vas="http://www.vettro.com/1/vas.xsd"> > > <vas:field name="serial">ABC</vas:field> > > </vas:object> > > </vas:update> > > </service> > > </ib> > > > > Would the following XPath extract the text node holding ABC: > > > > /service/vas:update/vas:object/vas:field[@name='serial']/text() > > > > Assuming the namespaces were declared: > > > > vas -> http://www.vettro.com/1/ib.xsd > > > > Code sample: > > > > xpf = XPathFactory.newInstance(); > > xpath = xpf.newXPath(); > > xpath.setNamespaceContext(new MyNamespaceContext()); > > XPathExpression e = xpath.compile(expression); > > Object o = e.evaluate(target, XPathConstants.NODESET); > > > > protected class MyNamespaceContext implements NamespaceContext > > { > > private Map namespaceMap = new HashMap(); > > > > public void addNamespace(String prefix, String url) > > { namespaceMap.put(prefix, url); } > > > > public void addNamespaces(Map map) > > { namespaceMap.putAll(map); } > > > > public String getNamespaceURI(String prefix) > > { > > String s = (String)namespaceMap.get(prefix); > > if (s == null) s = ""; > > return s; > > } > > > > public String getPrefix(String uri) > > { return null; } > > > > public Iterator getPrefixes(String namespaceURI) > > { return null; } > > } > > > > (Interestingly, Saxon never calls the namespace context > > implementation.) > > > > > > > > Thanks, > > > > > > John > > > > > > > > -------------------------------------------------------------- > > ----------- > > This SF.Net email is sponsored by the Moblin Your Move > > Developer's challenge Build the coolest Linux based > > applications with Moblin SDK & win great prizes Grand prize > > is a trip for two to an Open Source event anywhere in the > > world http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > saxon-help mailing list archived at > > http://saxon.markmail.org/ saxon-help@... > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge Build the coolest Linux based applications with Moblin SDK & win > great prizes Grand prize is a trip for two to an Open Source event anywhere > in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > saxon-help@... > https://lists.sourceforge.net/lists/listinfo/saxon-help ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
|
|
Re: NamespacesThe JAXP XPath API is designed for XPath 1.0, where an unprefixed name
always refers to a name in no namespace. So with this API you need to write /ib:ib/ib:service/vas:update/vas:object/vas:field[@name='serial']/text() and bind the prefix ib to http://www.vettro.com/1/ib.xsd If you use the s9api API, which is designed for XPath 2.0, you can declare a default namespace which will be associated with unprefixed names in the path expression. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: saxon-help-bounces@... > [mailto:saxon-help-bounces@...] On Behalf > Of John Baker > Sent: 09 August 2008 19:57 > To: Mailing list for the SAXON XSLT and XQuery processor > Subject: Re: [saxon] Namespaces > > Mike, > > How do I set the default namespace to be > http://www.vettro.com/1/ib.xsd, or perhaps I should be > asking, is this correct: > > /ib/service/vas:update/vas:object/vas:field[@name='serial']/text() > > You've said ib is in the NS http://www.vettro.com/1/ib.xsd, > so how do I tell the parser? Perhaps the getNamespaceURI > function should return the NS for empty string? > > > John > > On Saturday 09 August 2008 19:19:07 you wrote: > > Saxon searches the children of the document node for an > element named > > service, in the null namespace, finds that the only child of the > > document node is an element called ib, in namespace > > http://www.vettro.com/1/ib.xsd, and exits. > > > > But I would expect it to call your NamespaceContext implementation > > anyway, because it resolves all names in path expressions > at compile > > time, before it knows that the first step in the path > expression will select nothing. > > > > Michael Kay > > http://www.saxonica.com/ > > > > > -----Original Message----- > > > From: saxon-help-bounces@... > > > [mailto:saxon-help-bounces@...] On > Behalf Of John > > > Baker > > > Sent: 09 August 2008 18:38 > > > To: Mailing list for the SAXON XSLT and XQuery processor > > > Subject: [saxon] Namespaces > > > > > > Hi, > > > > > > If I have the following XML: > > > > > > <ib type="set" from="vas" id="2301181" to="DEV_LG" > > > xmlns="http://www.vettro.com/1/ib.xsd"> > > > <service username="leegardner"> > > > <vas:update xmlns:vas="http://www.vettro.com/1/vas.xsd"> > > > <vas:field name="serial">ABC</vas:field> > > > </vas:object> > > > </vas:update> > > > </service> > > > </ib> > > > > > > Would the following XPath extract the text node holding ABC: > > > > > > /service/vas:update/vas:object/vas:field[@name='serial']/text() > > > > > > Assuming the namespaces were declared: > > > > > > vas -> http://www.vettro.com/1/ib.xsd > > > > > > Code sample: > > > > > > xpf = XPathFactory.newInstance(); > > > xpath = xpf.newXPath(); > > > xpath.setNamespaceContext(new MyNamespaceContext()); > > > XPathExpression e = xpath.compile(expression); > > > Object o = e.evaluate(target, XPathConstants.NODESET); > > > > > > protected class MyNamespaceContext implements NamespaceContext > > > { > > > private Map namespaceMap = new HashMap(); > > > > > > public void addNamespace(String prefix, String url) > > > { namespaceMap.put(prefix, url); } > > > > > > public void addNamespaces(Map map) > > > { namespaceMap.putAll(map); } > > > > > > public String getNamespaceURI(String prefix) > > > { > > > String s = (String)namespaceMap.get(prefix); > > > if (s == null) s = ""; > > > return s; > > > } > > > > > > public String getPrefix(String uri) > > > { return null; } > > > > > > public Iterator getPrefixes(String namespaceURI) > > > { return null; } > > > } > > > > > > (Interestingly, Saxon never calls the namespace context > > > implementation.) > > > > > > > > > > > > Thanks, > > > > > > > > > John > > > > > > > > > > > > -------------------------------------------------------------- > > > ----------- > > > This SF.Net email is sponsored by the Moblin Your Move > Developer's > > > challenge Build the coolest Linux based applications with > Moblin SDK > > > & win great prizes Grand prize is a trip for two to an > Open Source > > > event anywhere in the world > > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > _______________________________________________ > > > saxon-help mailing list archived at > > > http://saxon.markmail.org/ saxon-help@... > > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > > > > ---------------------------------------------------------------------- > > --- This SF.Net email is sponsored by the Moblin Your Move > Developer's > > challenge Build the coolest Linux based applications with > Moblin SDK & > > win great prizes Grand prize is a trip for two to an Open > Source event > > anywhere in the world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > saxon-help mailing list archived at http://saxon.markmail.org/ > > saxon-help@... > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge Build the coolest Linux based > applications with Moblin SDK & win great prizes Grand prize > is a trip for two to an Open Source event anywhere in the > world http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > saxon-help mailing list archived at > http://saxon.markmail.org/ saxon-help@... > https://lists.sourceforge.net/lists/listinfo/saxon-help ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
|
|
Re: NamespacesThanks Mike.
I had a look through the samples but couldn't see an obvious s9api example - where would you suggest i start? Thanks again (it's Saturday dude, grab a wine and watch Casualty!). On Saturday 09 August 2008 20:22:10 you wrote: > The JAXP XPath API is designed for XPath 1.0, where an unprefixed name > always refers to a name in no namespace. So with this API you need to write > > > /ib:ib/ib:service/vas:update/vas:object/vas:field[@name='serial']/text() > > and bind the prefix ib to http://www.vettro.com/1/ib.xsd > > If you use the s9api API, which is designed for XPath 2.0, you can declare > a default namespace which will be associated with unprefixed names in the > path expression. > > Michael Kay > http://www.saxonica.com/ > > > -----Original Message----- > > From: saxon-help-bounces@... > > [mailto:saxon-help-bounces@...] On Behalf > > Of John Baker > > Sent: 09 August 2008 19:57 > > To: Mailing list for the SAXON XSLT and XQuery processor > > Subject: Re: [saxon] Namespaces > > > > Mike, > > > > How do I set the default namespace to be > > http://www.vettro.com/1/ib.xsd, or perhaps I should be > > asking, is this correct: > > > > /ib/service/vas:update/vas:object/vas:field[@name='serial']/text() > > > > You've said ib is in the NS http://www.vettro.com/1/ib.xsd, > > so how do I tell the parser? Perhaps the getNamespaceURI > > function should return the NS for empty string? > > > > > > John > > > > On Saturday 09 August 2008 19:19:07 you wrote: > > > Saxon searches the children of the document node for an > > > > element named > > > > > service, in the null namespace, finds that the only child of the > > > document node is an element called ib, in namespace > > > http://www.vettro.com/1/ib.xsd, and exits. > > > > > > But I would expect it to call your NamespaceContext implementation > > > anyway, because it resolves all names in path expressions > > > > at compile > > > > > time, before it knows that the first step in the path > > > > expression will select nothing. > > > > > Michael Kay > > > http://www.saxonica.com/ > > > > > > > -----Original Message----- > > > > From: saxon-help-bounces@... > > > > [mailto:saxon-help-bounces@...] On > > > > Behalf Of John > > > > > > Baker > > > > Sent: 09 August 2008 18:38 > > > > To: Mailing list for the SAXON XSLT and XQuery processor > > > > Subject: [saxon] Namespaces > > > > > > > > Hi, > > > > > > > > If I have the following XML: > > > > > > > > <ib type="set" from="vas" id="2301181" to="DEV_LG" > > > > xmlns="http://www.vettro.com/1/ib.xsd"> > > > > <service username="leegardner"> > > > > <vas:update xmlns:vas="http://www.vettro.com/1/vas.xsd"> > > > > <vas:field name="serial">ABC</vas:field> > > > > </vas:object> > > > > </vas:update> > > > > </service> > > > > </ib> > > > > > > > > Would the following XPath extract the text node holding ABC: > > > > > > > > /service/vas:update/vas:object/vas:field[@name='serial']/text() > > > > > > > > Assuming the namespaces were declared: > > > > > > > > vas -> http://www.vettro.com/1/ib.xsd > > > > > > > > Code sample: > > > > > > > > xpf = XPathFactory.newInstance(); > > > > xpath = xpf.newXPath(); > > > > xpath.setNamespaceContext(new MyNamespaceContext()); > > > > XPathExpression e = xpath.compile(expression); > > > > Object o = e.evaluate(target, XPathConstants.NODESET); > > > > > > > > protected class MyNamespaceContext implements NamespaceContext > > > > { > > > > private Map namespaceMap = new HashMap(); > > > > > > > > public void addNamespace(String prefix, String url) > > > > { namespaceMap.put(prefix, url); } > > > > > > > > public void addNamespaces(Map map) > > > > { namespaceMap.putAll(map); } > > > > > > > > public String getNamespaceURI(String prefix) > > > > { > > > > String s = (String)namespaceMap.get(prefix); > > > > if (s == null) s = ""; > > > > return s; > > > > } > > > > > > > > public String getPrefix(String uri) > > > > { return null; } > > > > > > > > public Iterator getPrefixes(String namespaceURI) > > > > { return null; } > > > > } > > > > > > > > (Interestingly, Saxon never calls the namespace context > > > > implementation.) > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > John > > > > > > > > > > > > > > > > -------------------------------------------------------------- > > > > ----------- > > > > This SF.Net email is sponsored by the Moblin Your Move > > > > Developer's > > > > > > challenge Build the coolest Linux based applications with > > > > Moblin SDK > > > > > > & win great prizes Grand prize is a trip for two to an > > > > Open Source > > > > > > event anywhere in the world > > > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > > _______________________________________________ > > > > saxon-help mailing list archived at > > > > http://saxon.markmail.org/ saxon-help@... > > > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > > > ---------------------------------------------------------------------- > > > > > --- This SF.Net email is sponsored by the Moblin Your Move > > > > Developer's > > > > > challenge Build the coolest Linux based applications with > > > > Moblin SDK & > > > > > win great prizes Grand prize is a trip for two to an Open > > > > Source event > > > > > anywhere in the world > > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > _______________________________________________ > > > saxon-help mailing list archived at http://saxon.markmail.org/ > > > saxon-help@... > > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > > > -------------------------------------------------------------- > > ----------- > > This SF.Net email is sponsored by the Moblin Your Move > > Developer's challenge Build the coolest Linux based > > applications with Moblin SDK & win great prizes Grand prize > > is a trip for two to an Open Source event anywhere in the > > world http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > saxon-help mailing list archived at > > http://saxon.markmail.org/ saxon-help@... > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge Build the coolest Linux based applications with Moblin SDK & win > great prizes Grand prize is a trip for two to an Open Source event anywhere > in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > saxon-help mailing list archived at http://saxon.markmail.org/ > saxon-help@... > https://lists.sourceforge.net/lists/listinfo/saxon-help ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
|
|
Re: NamespacesIn the Saxon 9.1 saxon-resources distribution samples/java/S9APIExamples.java Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: saxon-help-bounces@... > [mailto:saxon-help-bounces@...] On Behalf > Of John Baker > Sent: 09 August 2008 20:26 > To: Mailing list for the SAXON XSLT and XQuery processor > Subject: Re: [saxon] Namespaces > > Thanks Mike. > > I had a look through the samples but couldn't see an obvious > s9api example - where would you suggest i start? > > Thanks again (it's Saturday dude, grab a wine and watch Casualty!). > > > On Saturday 09 August 2008 20:22:10 you wrote: > > The JAXP XPath API is designed for XPath 1.0, where an > unprefixed name > > always refers to a name in no namespace. So with this API > you need to > > write > > > > > > > /ib:ib/ib:service/vas:update/vas:object/vas:field[@name='serial']/text > > () > > > > and bind the prefix ib to http://www.vettro.com/1/ib.xsd > > > > If you use the s9api API, which is designed for XPath 2.0, you can > > declare a default namespace which will be associated with > unprefixed > > names in the path expression. > > > > Michael Kay > > http://www.saxonica.com/ > > > > > -----Original Message----- > > > From: saxon-help-bounces@... > > > [mailto:saxon-help-bounces@...] On > Behalf Of John > > > Baker > > > Sent: 09 August 2008 19:57 > > > To: Mailing list for the SAXON XSLT and XQuery processor > > > Subject: Re: [saxon] Namespaces > > > > > > Mike, > > > > > > How do I set the default namespace to be > > > http://www.vettro.com/1/ib.xsd, or perhaps I should be asking, is > > > this correct: > > > > > > /ib/service/vas:update/vas:object/vas:field[@name='serial']/text() > > > > > > You've said ib is in the NS > http://www.vettro.com/1/ib.xsd, so how > > > do I tell the parser? Perhaps the getNamespaceURI > function should > > > return the NS for empty string? > > > > > > > > > John > > > > > > On Saturday 09 August 2008 19:19:07 you wrote: > > > > Saxon searches the children of the document node for an > > > > > > element named > > > > > > > service, in the null namespace, finds that the only > child of the > > > > document node is an element called ib, in namespace > > > > http://www.vettro.com/1/ib.xsd, and exits. > > > > > > > > But I would expect it to call your NamespaceContext > implementation > > > > anyway, because it resolves all names in path expressions > > > > > > at compile > > > > > > > time, before it knows that the first step in the path > > > > > > expression will select nothing. > > > > > > > Michael Kay > > > > http://www.saxonica.com/ > > > > > > > > > -----Original Message----- > > > > > From: saxon-help-bounces@... > > > > > [mailto:saxon-help-bounces@...] On > > > > > > Behalf Of John > > > > > > > > Baker > > > > > Sent: 09 August 2008 18:38 > > > > > To: Mailing list for the SAXON XSLT and XQuery processor > > > > > Subject: [saxon] Namespaces > > > > > > > > > > Hi, > > > > > > > > > > If I have the following XML: > > > > > > > > > > <ib type="set" from="vas" id="2301181" to="DEV_LG" > > > > > xmlns="http://www.vettro.com/1/ib.xsd"> > > > > > <service username="leegardner"> > > > > > <vas:update xmlns:vas="http://www.vettro.com/1/vas.xsd"> > > > > > <vas:field name="serial">ABC</vas:field> > > > > > </vas:object> > > > > > </vas:update> > > > > > </service> > > > > > </ib> > > > > > > > > > > Would the following XPath extract the text node holding ABC: > > > > > > > > > > > /service/vas:update/vas:object/vas:field[@name='serial']/text() > > > > > > > > > > Assuming the namespaces were declared: > > > > > > > > > > vas -> http://www.vettro.com/1/ib.xsd > > > > > > > > > > Code sample: > > > > > > > > > > xpf = XPathFactory.newInstance(); > > > > > xpath = xpf.newXPath(); > > > > > xpath.setNamespaceContext(new MyNamespaceContext()); > > > > > XPathExpression e = xpath.compile(expression); > > > > > Object o = e.evaluate(target, XPathConstants.NODESET); > > > > > > > > > > protected class MyNamespaceContext implements > NamespaceContext > > > > > { > > > > > private Map namespaceMap = new HashMap(); > > > > > > > > > > public void addNamespace(String prefix, String url) > > > > > { namespaceMap.put(prefix, url); } > > > > > > > > > > public void addNamespaces(Map map) > > > > > { namespaceMap.putAll(map); } > > > > > > > > > > public String getNamespaceURI(String prefix) > > > > > { > > > > > String s = (String)namespaceMap.get(prefix); > > > > > if (s == null) s = ""; > > > > > return s; > > > > > } > > > > > > > > > > public String getPrefix(String uri) > > > > > { return null; } > > > > > > > > > > public Iterator getPrefixes(String namespaceURI) > > > > > { return null; } > > > > > } > > > > > > > > > > (Interestingly, Saxon never calls the namespace context > > > > > implementation.) > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > John > > > > > > > > > > > > > > > > > > > > -------------------------------------------------------------- > > > > > ----------- > > > > > This SF.Net email is sponsored by the Moblin Your Move > > > > > > Developer's > > > > > > > > challenge Build the coolest Linux based applications with > > > > > > Moblin SDK > > > > > > > > & win great prizes Grand prize is a trip for two to an > > > > > > Open Source > > > > > > > > event anywhere in the world > > > > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > > > _______________________________________________ > > > > > saxon-help mailing list archived at > http://saxon.markmail.org/ > > > > > saxon-help@... > > > > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > > > > > > -------------------------------------------------------------------- > > > -- > > > > > > > --- This SF.Net email is sponsored by the Moblin Your Move > > > > > > Developer's > > > > > > > challenge Build the coolest Linux based applications with > > > > > > Moblin SDK & > > > > > > > win great prizes Grand prize is a trip for two to an Open > > > > > > Source event > > > > > > > anywhere in the world > > > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > > _______________________________________________ > > > > saxon-help mailing list archived at http://saxon.markmail.org/ > > > > saxon-help@... > > > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > > > > > -------------------------------------------------------------- > > > ----------- > > > This SF.Net email is sponsored by the Moblin Your Move > Developer's > > > challenge Build the coolest Linux based applications with > Moblin SDK > > > & win great prizes Grand prize is a trip for two to an > Open Source > > > event anywhere in the world > > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > > _______________________________________________ > > > saxon-help mailing list archived at > > > http://saxon.markmail.org/ saxon-help@... > > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > > > > ---------------------------------------------------------------------- > > --- This SF.Net email is sponsored by the Moblin Your Move > Developer's > > challenge Build the coolest Linux based applications with > Moblin SDK & > > win great prizes Grand prize is a trip for two to an Open > Source event > > anywhere in the world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > saxon-help mailing list archived at http://saxon.markmail.org/ > > saxon-help@... > > https://lists.sourceforge.net/lists/listinfo/saxon-help > > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge Build the coolest Linux based > applications with Moblin SDK & win great prizes Grand prize > is a trip for two to an Open Source event anywhere in the > world http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > saxon-help mailing list archived at > http://saxon.markmail.org/ saxon-help@... > https://lists.sourceforge.net/lists/listinfo/saxon-help ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@... https://lists.sourceforge.net/lists/listinfo/saxon-help |
| Free Forum Powered by Nabble | Forum Help |