Re: newbie XPATH newsgroup ?
"rvj" <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Organization | Another Netscape Collabra Server User |
| Message-ID | <[email protected]> |
.... and finally ( after a nights sleep) I guess what I have been struggling
to decide is whether there is
a) a need for CASCADING NAMESPACES and
b) how this could be implimented
My previous example as XPATH as XML was a little off-the-wall but with a few
minor changes it probably could be useful for ensuring that multiple
namespace declarations are applied correctly. It may even be useful for
versioning.
In the example below xmlns:ABC="foo1" is defined in the root element. This
implies that "foo1" is inherited declaration for the ABC prefix except if
the ABC prefix has a similar parent, in which case "foo2" should be used
<xpath xmlns="foo0" xmlns:ABC="foo1" xpath="/">
<xpath xpath="ABC[@id='x']">
<xpath xmlns:ABC="foo2" xpath="ABC[@id='y']"/>
<ns1:author>
</xpath>
I assume (*) that ANY XPath expression can be converted to an XML
structure with mininal overhead. ie just add a containing element called
XPath. For example a union operation could be simply expressed as
<xpath xpath="//AAA|//BBB"/>
or expanded as
<xpath xpath="//">
<xpath xpath="AAA" />
<xpath xpath="BBB" />
</xpath>
The real advantage is that cascading namespaces ensures namspaces are
applied correctly.
(*) Am I correct about this?
"rvj" <[email protected]> wrote in message
news:[email protected]...
> PPS I guess also that the <xpath/> element would also need to define the
> default namespace for the xpath attribute
>
> <xpath xmlns="www.xpath.namspace" xpath="xpathstring"/>
>
> ..............lost in (name)space ??????????????
>
>
> "rvj" <[email protected]> wrote in message
> news:[email protected]...
> > PS
> >
> > I'm not sure where the attachment came from in the previous post so
> IGNORE
> > it!
> >
> >
> > "rvj" <[email protected]> wrote in message
> > news:[email protected]...
> > > OK
> > >
> > > > > I'm not sure about your question,
> > >
> > > First of all neither am I !
> > >
> > > This is day #6 of my XPath investigations.
> > >
> > > What I am trying to understand are the implications of namespaces for
> > XPath
> > > expressions. !!
> > >
> > > As I understand it, XPath support two basic namespace approaches
> > >
> > > 1) Using QNames which in turn define two distinct syntaxes
> > > a) URL based which are RESOLVABLE because they point to real
locations
> > > (versioning)
> > > b) URN based which are abstract references but are essentially
> > UNRESOLVABLE
> > > !
> > >
> > > 2) Universal/Expanded names which as I understand are NOT XML
namespace
> > > recommendations BUT nevertheless are an appendix to the XML Namspace
> > > specification and provide a physical reference for a namespace !!
> > >
> > > Universal/Expanded names have NOT been recommended purely because
they
> > are
> > > a little more verbose.
> > >
> > > *******************************************************
> > >
> > > Thats just the introduction !!!
> > >
> > > Now XPATH (as far as I am concerned ) has nothing to do wish XSL!
(XSL
> > and
> > > XSLT are just utilities)
> > >
> > > ********************************************************
> > > The issue is HOW BEST TO DECLARE XPATH NAMESPACES
> > > ********************************************************
> > >
> > > Firstly, should it be
> > >
> > > a) universal namespaces OR
> > > b) namespace versioning
> > >
> > > So if we take a simple example of multiple namespace document a
> > > non-resolvable XPath expression such as
> > >
> > > /ns1:author/ns2:author
> > >
> > > what is the best way of converting this to a resolvable XPath
expression
> > >
> > > Currently (if you are using the MS parser) you identify the namespaces
> > using
> > > a separate property called SelectNamespaces.
> > >
> > > An XPath expression assumes that the document contains the relevant
> > > namespace declarations
> > >
> > > xpath="/ns1:author[@id='x']/ns2:author[@id='y']"
> > >
> > > However resolvable references can be provided (for verification
> purposes)
> > > using
> > >
> > > a) universal/expanded names
> > >
> > > xpath=
> > >
> >
>
"<{http://www.somepath/or/other}author[@id='x']/<{http://www.someotherpath/o
> > > r/other}:author[@id='y']"
> > >
> > >
> > > b) namespace versioning
> > >
> > >
> > >
> >
>
xpath="http:/www.namespace1/author[@id='x']/http:/www.namespace2/author[@id=
> > > 'y']"
> > >
> > >
> **************************************************************************
> > >
> > > Secondly, (and this is off-the-wall stuff), it appears that it would
be
> > much
> > > simpler to declare namespaces using an XML XPATH structure that
mimics
> > the
> > > structure of the source document (XML)
> > >
> > > For example, lets assume that an XPATH expression COULD also be
> > represented
> > > as an XML structure via an element called XPATH with an attribute
called
> > > XPATH.
> > >
> > > For example
> > >
> > > <xpath xpath= "/ns1:author[@id='x']/ns2:author[@id='y'] />
> > >
> > > In otherwords instead of parsing a literal string, the parser could
> accept
> > > an XML structure !
> > >
> > > It appears that this is also simpler to declare resolveable XPATH
> > expression
> > > using standard namespace declarations. For example
> > >
> > > <xpath>
> > > <ns1:author xmlns:ns1="www.namespace1" xpath="@id='x'">
> > > <ns2:author xmlns:ns2="www.namespace2"
xpath="@id='y'"/>
> > > <ns1:author>
> > > </xpath>
> > >
> > > ****************************************************************
> > > Does any of this make sense ?
> > > ****************************************************************
> > >
> > > BTW The article that has provided the basis of my confusion is
> > >
> > >
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/htm
> > > l/xml05202002.asp
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > "Markus Siebeneicher" <[email protected]> wrote in message
> > > news:[email protected]...
> > > > Markus Siebeneicher wrote:
> > > >
> > > > > rvj wrote:
> > > > >
> > > > >> correction : something like
> > > > >>
> > > > >>
> > > > >>> <ns1:author ns1:author="www.foo1" xpath="author[@id='x']>
> > > > >>> <ns2:author ns2:author=www.foo2
> xpath="author[@id='y']/>
> > > > >>> <ns1:author>
> > > > >>>
> > > > >>
> > > > >>
> > > > >> "rvj" <[email protected]> wrote in message
> > > > >> news:[email protected]...
> > > > >>
> > > > >>> I think the correct term is serialized but really what I am
> trying
> > to
> > > > >>> understand is XPath with multiple namespaces
> > > > >>>
> > > > >>> For example if you search for an attribute called 'author' but
> with
> > > > >>> multiple namespaces. Given
> > > > >>>
> > > > >>> xpath= "/ns1:author[@id='x']/ns2:author[@id='y']
> > > > >>>
> > > > >>> is it possible to declare the namespace references in the xpath?
> > > > >>>
> > > > >>> It seems that a serialized xpath format would make this a lot
> > > > >>> easier to
> > > > >>> read
> > > > >>>
> > > > >>> <ns1:author ns1:author="www.foo1" xpath="@id='x'>
> > > > >>> <ns2:author ns2:author=www.foo2 xpath="@id='y'/>
> > > > >>> <ns1:author>
> > > > >>>
> > > > >>> Any recommended reading for XPath+multiple namespaces?
> > > > >>>
> > > > >>>
> > > > >>> "rvj" <[email protected]> wrote in message
> > > > >>> news:[email protected]...
> > > > >>>
> > > > >>>> a) is there a XPath newsgroup
> > > > >>>>
> > > > >>>> b) very simply all I want to know is there is a mechanism
> > > > >>>
> > > > >>>
> > > > >>> (exists/proposed)
> > > > >>>
> > > > >>>> for switching between a compact XPath representation and a more
> > > verbose
> > > > >>>
> > > > >>>
> > > > >>> XML
> > > > >>>
> > > > >>>> structured representation ?
> > > > >>>>
> > > > >>>> where
> > > > >>>>
> > > > >>>> /provider[@id=123]/library[@id=234]/detail[@id=345]/*
> > > > >>>>
> > > > >>>> can be alternatively represented something like
> > > > >>>>
> > > > >>>> <provider xpath="[@id=123]" >
> > > > >>>> <library xpath="[@id=234]" >
> > > > >>>> <detail xpath="[id=345]/*" />
> > > > >>>> </library>
> > > > >>>> </provider>
> > > > >>>>
> > > > >>>>
> > > > >>>
> > > > >>
> > > > >>
> > > > >
> > > > > I'm not sure about your question, but maybe this is a usefull
> > suggestion
> > > > > to your research ->
> > > > >
/*[name()='ns1:author'][@id='123']/*[name()='ns2:author'][@id='234']
> > > >
> > > > a proper mailing list about xsl and xpath is definitly the xsl
> mulberry
> > > > list, (http://www.mulberrytech.com/xsl/xsl-list).
> > >
> > >
> > >
> >
> >
>
>