[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Autogenerating XPath from XML?


Subject: [xsl] Autogenerating XPath from XML?
From: "Kenji Hollis" <kenji@xxxxxxxxxxxx>
Date: Sun, 29 Sep 2002 11:49:40 -0700

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



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords