This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Autogenerating XPath from XML?
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Sun, 29 Sep 2002 21:43:29 -0700 (PDT)
- Subject: [xsl] Re: Autogenerating XPath from XML?
- Reply-to: xsl-list at lists dot mulberrytech dot com
--- "Kenji Hollis" <kenji at ptdmicro dot com> wrote:
> Hi all you programmers out there
>
> I've looked through the list and not found an answer for this
> question,
> so
> sorry if someone's already responded to this question.
>
> I'm looking for a way to programatically create a list of XPaths
> based
> on a
> given XML document. I can easily create an XPath that will sort of
> work
> with a standard XML document that doesn't have multiple items of the
> same
> name. For instance:
>
> <A>
> <B>
> <C>data</C>
> </B>
> <D>
> <X>y z</X>
> </D>
> </A>
>
> Becomes:
>
> //A
> //A/B
> //A/B/C
> //A/B/D
> //A/B/D/X
>
> My problem is, when I get to this:
>
> <A>
> <B>
> <VALUE/>
> </B>
> <B>
> <VALUE/>
> </B>
> <B>
> <VALUE/>
> </B>
> </A>
>
> I want:
>
> //A
> //A/B[1]
> //A/B[1]/VALUE
> //A/B[2]
> //A/B[2]/VALUE
> //A/B[3]
> //A/B[3]/VALUE
>
> I've tried several ways to do this, and I've tried looking through
> several
> tutorials. I'm banging my head on this one, as this is
> programmatically
> very difficult. Mentally, this is a piece-of-cake problem.
>
> Has anyone encountered this type of problem, created a piece of code
> that
> will generate what I'm looking for, or does anyone know of a project
> that
> has done this?
>
> Thanks in advance.
> -- Kenji
See for example the snippet "Build an XPath Expression for a Node":
http://www.topxml.com/code/default.asp?p=3&id=v20010323001030
Hope this helped.
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list