Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 23rd, 2004, 03:54 PM
Registered User
 
Join Date: Aug 2004
Location: Pascagoula, MS, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL processing question..

I have an xml file that looks like this (vaguely):

<AppvInvDoc>
  <AppvInv ActionCode="U">
    <AH>
      stuff...
    </AH>
    <AL>
      more stuff...
      <AD>
        still more stuff
      </AD>
      <AD>
        still more stuff
      </AD>
    </AL>
    <AL>
      more stuff
      <AD>
        still more stuff
      </AD>
    </AL>
  </AppvInv>
</AppvInvDoc>

I have to use an XSLT to turn this into a flat file. The example above should result in three different lines. For each AD that's processed, I need access to it's parent AL element, and the AH element at the top.

What's the right witches brew of matches, for-eaches and so forth? I've been playing with this for about a day and I can't wrap my head around the answer.

Thanks,

Eric

Reply With Quote
  #2 (permalink)  
Old August 24th, 2004, 07:58 AM
Authorized User
 
Join Date: Jul 2004
Location: , , .
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm afraid it's going to be difficult to be more specific without knowing exactly what you want to get from accessing each of these nodes, but in general:

<xsl:template match="/">
    <xsl:apply-templates select="//AD" />
</xsl:template>

<xsl:template match="/">
    do stuff here
</xsl:template>

will match each of your AD nodes.

Using select="parent::*" within the AD template will select the parent node of the current AD node you are processing.

If you only ever have one AH node then you can always access it with simply //AH (or the full path - i'm just being lazy here).
Personally I wouldn't mix text and elements within a node i.e.

<elem>
   some text
   <an_elem />
</elem>

because it is a pain it the buttski to separate the text later. Depending on the size of the text, consider using an attribute; something like:

<elem some_text="put your text here">
  <an_elem />
</elem>

You can get this out later using select="elem@some_text"

Or putting a different named node above the AD nodes.

I hope that's helpful.

hmk
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional processing in XSL francislang XSLT 2 March 18th, 2008 12:04 AM
xsl question bluisana XSLT 7 September 15th, 2005 01:34 AM
xsl:sort Question kwilliams XSLT 6 July 18th, 2005 08:39 AM
xsl:if question rdavisiii XSLT 2 March 30th, 2005 01:40 PM
Create processing instruction in XSL hbcontract XML 6 May 7th, 2004 12:14 PM



All times are GMT -4. The time now is 11:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.