Connecting Tech Pros Worldwide Help | Site Map

XSLT & The Noob........

Newbie
 
Join Date: Apr 2009
Posts: 4
#1: Apr 23 '09
Folks -

I have a stylesheet difficulty that I'm sure most of you could probably solve in moments - this thing has had me stymied for parts of several days......I've attached the stylesheet and some sample data.

The stylesheet is by no means pretty, but it's supposed to output HTML for the body of an email. There are Header and OrderResponseBody children to the OrderResponse parent(CIDX). The problem is that I need to pull a date out of the XML in the Header nodeset while processing the OrderResponseBody nodeset. The closest I've been able to come to suceeding is by using 'following-sibling' although what I really need is something like a 'following-sibling-or-self'.

The stylesheet has some comments, I'm dealing with 'Date Acknowledged' and no amount of blood, sweat and tears has helped me find a solution to this particular problem! I had posted on another forum but I guess they're all on vacation!

Thanks For Helping Out!

Bob
Attached Files
File Type: zip FertXML.zip (2.9 KB, 6 views)
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#2: Apr 23 '09

re: XSLT & The Noob........


I see only one date in the header section so you can access that (more or less) directly.
you can also "save" the date in <xsl:variable> for later usage.
Newbie
 
Join Date: Apr 2009
Posts: 4
#3: Apr 23 '09

re: XSLT & The Noob........


Hi Dormilich -

The CIDX standard allows for 2 date fields in the Header:
Header 1..1
ThisDocumentIdentifier 1..1
ThisDocumentDateTime 1..1
RequestingDocumentIdentifier 0..1
RequestingDocumentDateTime 0..1
From 1..1
To 1..1

I need both anyway.

The stylesheet is using
<xsl:for-each select="./OrderResponseBody"> which seems to be preventing me from puilling in the date/time elements from the header.

I've tried selecting Header/RequestingDocumentDateTime/DateTime/text()) and that returns nothing. I've also tried preceeding-sibling and that returns the same date for all 3 orders in the sample data. As you can see from the XSLT, I'm stuck using version 1.0 and I'm forced to use a really ugly conversion from 'Zulu' time as well. So far, the only thing that has gotten me even close is the following-sibling currently in the XSLT but that returns 2 of the 3 dates.

Bob
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#4: Apr 23 '09

re: XSLT & The Noob........


is there any clear identification which header belongs to which body, except that the header precedes the body in the xml?
Newbie
 
Join Date: Apr 2009
Posts: 4
#5: Apr 23 '09

re: XSLT & The Noob........


None whatsoever - this is strictly a matter of order/precedence:

Header
ResponseBody
Header
ResponseBody
Header
ResponseBody
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#6: Apr 24 '09

re: XSLT & The Noob........


preceding-sibling::Header[1]/restofxpath...

?
Newbie
 
Join Date: Apr 2009
Posts: 4
#7: Apr 24 '09

re: XSLT & The Noob........


Thanks JKM -
I got it working this afternoon by changing the XSLT to instantiate based on Header and changing the pathing to select following sibling nodes. I do appreciate the help!

Bob
Reply