Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 23rd, 2009, 12:44 PM
Registered User
 
Join Date: Apr 2009
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default XSLT Not Pulling Sibling Data?

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.

Understand something right up front - this is ALL new to me. Yes, I've checked forums for answers and made other postings. Yes, I have several books on XSLT and XPath so I have been doing the 'due diligence' as it were. And I'm sure I've made plenty of mistakes with this mess! For the time being, I'm forced to use XPath version 1.0 due to integration limitations with a software package.

Final goal is to output HTML for the body of an email. This is a CIDX 5.0 message and the schema is OrderResponse.

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'.

In the XSLT I'm working with 'Date Acknowledged' although 'Date Received' has the same issue. The sample data has elements for 'Date Acknowledged'.
Thanks For Helping Out! Code and Data Follows......
Bob

================== CURRENT RESULT =======================
Code:
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>
 <body><b>The following order(s) have been received and acknowledged by the supplier:</b><table border="1">
   <tr>
    <th bgcolor="#728FCE">Date Received</th>
    <th bgcolor="#728FCE">Date Acknowledged</th>
    <th bgcolor="#728FCE">Order</th>
    <th bgcolor="#728FCE">Release</th>
    <th bgcolor="#728FCE">Ship From</th>
    <th bgcolor="#728FCE">Ship To</th>
    <th bgcolor="#728FCE">Line</th>
    <th bgcolor="#728FCE">Product Name</th>
    <th bgcolor="#728FCE">Quantity</th>
    <th bgcolor="#728FCE">UOM</th>
    <th bgcolor="#728FCE">Status</th>
    <th bgcolor="#728FCE">Reason</th>
   </tr>
   <tr>
    <td>N/A</td>
    <td>04/17/2009 8:34:16 PM</td>
    <td>OD2314874</td>
    <td>N/A</td>
    <td>Bensensville</td>
    <td>SOUTHERN STATES COOP, INC.</td>
    <td>10</td>
    <td>First Product</td>
    <td>100.000</td>
    <td>STN</td>
    <td><FONT COLOR="FF0000">Pending</FONT></td>
    <td><FONT COLOR="FF0000"></FONT></td>
   </tr>
   <tr>
    <td>N/A</td>
    <td>04/18/2009 10:34:20 PM</td>
    <td>OD2314875</td>
    <td>N/A</td>
    <td>Mars</td>
    <td>SOUTHERN STATES COOP, INC.</td>
    <td>10</td>
    <td>Second Product</td>
    <td>200.000</td>
    <td>STN</td>
    <td><FONT COLOR="FF0000">Pending</FONT></td>
    <td><FONT COLOR="FF0000"></FONT></td>
   </tr>
   <tr>
    <td>N/A</td>
    <td>// :: AM</td>
    <td>OD2314876</td>
    <td>N/A</td>
    <td>Venus</td>
    <td>SOUTHERN STATES COOP, INC.</td>
    <td>10</td>
    <td>Third Product</td>
    <td>300.000</td>
    <td>STN</td>
    <td><FONT COLOR="FF0000">Pending</FONT></td>
    <td><FONT COLOR="FF0000"></FONT></td>
   </tr>
  </table>
 </body>
</html>
================== XSLT CODE =============================
Code:
<?xml version="1.0"?>
<?altova_samplexml file:///C:/XML/FertXML/Fert_OrderResponse.xml?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<head/>
<body>
<xsl:apply-templates select="OrderResponse">
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<xsl:template match="OrderResponse">
<b>The following order(s) have been received and acknowledged by the supplier:</b>
<table border="1">
<tr>
<th bgcolor="#728FCE">Date Received</th>
<th bgcolor="#728FCE">Date Acknowledged</th>
<th bgcolor="#728FCE">Order</th>
<th bgcolor="#728FCE">Release</th>
<th bgcolor="#728FCE">Ship From</th>
<th bgcolor="#728FCE">Ship To</th>
<th bgcolor="#728FCE">Line</th>
<th bgcolor="#728FCE">Product Name</th>
<th bgcolor="#728FCE">Quantity</th>
<th bgcolor="#728FCE">UOM</th>
<th bgcolor="#728FCE">Status</th>
<th bgcolor="#728FCE">Reason</th>
</tr>
<xsl:for-each select="./OrderResponseBody">
<xsl:sort select="./OrderResponseProperties/PurchaseOrderNumber/DocumentIdentifier"/>
<tr>
<!--Date Received-->
<xsl:choose>
<xsl:when test="string-length(preceding-sibling::*/RequestingDocumentDateTime/DateTime/text()) > 0">
<td>
<xsl:value-of select="concat(substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,6,2),'/',substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,9,2),'/',substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,1,4),' ',substring(substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,12,2),1,not(substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,12,2)>12)*2),substring(number(substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,12,2))-12,1,(substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,12,2)>12)*2),':',substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,15,2),':',substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,18,2),' ',substring('AM',1,not(substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,12,2)>=12)*2),substring('PM',1,(substring(preceding-sibling::*/RequestingDocumentDateTime/DateTime,12,2)>=12)*2))"/>
</td>
</xsl:when>
<xsl:otherwise>
<td>N/A</td>
</xsl:otherwise>
</xsl:choose>
<!--Date Acknowledged-->
<td>
<xsl:value-of select="concat(substring(following-sibling::*/ThisDocumentDateTime/DateTime,6,2),'/',substring(following-sibling::*/ThisDocumentDateTime/DateTime,9,2),'/',substring(following-sibling::*/ThisDocumentDateTime/DateTime,1,4),' ',substring(substring(following-sibling::*/ThisDocumentDateTime/DateTime,12,2),1,not(substring(following-sibling::*/ThisDocumentDateTime/DateTime,12,2)>12)*2),substring(number(substring(following-sibling::*/ThisDocumentDateTime/DateTime,12,2))-12,1,(substring(following-sibling::*/ThisDocumentDateTime/DateTime,12,2)>12)*2),':',substring(following-sibling::*/ThisDocumentDateTime/DateTime,15,2),':',substring(following-sibling::*/ThisDocumentDateTime/DateTime,18,2),' ',substring('AM',1,not(substring(following-sibling::*/ThisDocumentDateTime/DateTime,12,2)>=12)*2),substring('PM',1,(substring(following-sibling::*/ThisDocumentDateTime/DateTime,12,2)>=12)*2))"/>
</td>
<!--Purchase Order Number-->
<td>
<xsl:value-of select="./OrderResponseProperties/PurchaseOrderNumber/DocumentIdentifier"/>
</td>
<!--Release Number-->
<xsl:choose>
<xsl:when test="string-length(./OrderResponseProperties/ReferenceInformation/ReleaseNumber/text()) > 0">
<td>
<xsl:value-of select="./OrderResponseProperties/ReferenceInformation/ReleaseNumber"/>
</td>
</xsl:when>
<xsl:when test="string-length(./OrderResponseProperties/ReferenceInformation[@ReferenceType='ReleaseNumber']/DocumentReference/ReleaseNumber/text()) > 0">
<td>
<xsl:value-of select="./OrderResponseProperties/ReferenceInformation[@ReferenceType='ReleaseNumber']/DocumentReference/ReleaseNumber"/>
</td>
</xsl:when>
<xsl:otherwise>
<td>N/A</td>
</xsl:otherwise>
</xsl:choose>
<!--Ship From-->
<xsl:choose>
<xsl:when test="string-length(./OrderResponseProperties/OtherPartner[@PartnerRole='ShipFrom']/PartnerInformation/PartnerName/text()) >0">
<td>
<xsl:value-of select="./OrderResponseProperties/OtherPartner[@PartnerRole='ShipFrom']/PartnerInformation/PartnerName"/>
</td>
</xsl:when>
<xsl:when test="string-length(./OrderResponsePartners/OtherPartner[@PartnerRole='ShipFrom']/PartnerInformation/PartnerName/text()) >0">
<td>
<xsl:value-of select="./OrderResponsePartners/OtherPartner[@PartnerRole='ShipFrom']/PartnerInformation/PartnerName"/>
</td>
</xsl:when>
</xsl:choose>
<!--Ship To-->
<td>
<xsl:value-of select="./OrderResponsePartners/ShipTo/PartnerInformation/PartnerName"/>
</td>
<!--Line Number-->
<td>
<xsl:value-of select="./OrderResponseDetails/OrderResponseProductLineItem/LineNumber"/>
</td>
<!--Product Name-->
<td>
<xsl:value-of select="./OrderResponseDetails/OrderResponseProductLineItem/ProductIdentification/ProductDescription"/>
</td>
<!--Quantity-->
<td>
<xsl:value-of select="./OrderResponseDetails/OrderResponseProductLineItem/ProductQuantity/Measurement/MeasurementValue"/>
</td>
<!--UOM-->
<td>
<xsl:value-of select="./OrderResponseDetails/OrderResponseProductLineItem/ProductQuantity/Measurement/UnitOfMeasureCode"/>
</td>
<!--Status-->
<xsl:choose>
<xsl:when test="string-length(./OrderResponseDetails/OrderResponseProductLineItem/LineStatus/text()) > 0">
<td>
<FONT COLOR="FF0000">
<xsl:value-of select="./OrderResponseDetails/OrderResponseProductLineItem/LineStatus"/>
</FONT>
</td>
</xsl:when>
<xsl:otherwise>
<td>Accepted</td>
</xsl:otherwise>
</xsl:choose>
<!--Reason-->
<xsl:choose>
<xsl:when test="(./OrderResponseDetails/OrderResponseProductLineItem/ResponseStatus/ResponseStatusReasonIdentifier/text()) = '099'">
<td>
<FONT COLOR="FF0000">
<xsl:value-of select="./OrderResponseDetails/OrderResponseProductLineItem/ResponseStatus/ResponseStatusComments"/>
</FONT>
</td>
</xsl:when>
<xsl:when test="(./OrderResponseDetails/OrderResponseProductLineItem/ResponseStatus/ResponseStatusReasonIdentifier/text()) != '099'">
<td>
<FONT COLOR="FF0000">
<xsl:value-of select="./OrderResponseDetails/OrderResponseProductLineItem/ResponseStatus/ResponseStatusReasonDescription"/>
</FONT>
</td>
</xsl:when>
<xsl:otherwise>
<td>N/A</td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

========================= DATA =========================
<?xml version="1.0"?>
<OrderResponse>
<Header>
<ThisDocumentIdentifier>
<DocumentIdentifier>7271026</DocumentIdentifier>
</ThisDocumentIdentifier>
<ThisDocumentDateTime>
<DateTime DateTimeQualifier="On">2009-04-16T20:34:12Z</DateTime>
</ThisDocumentDateTime>
<From>
<PartnerInformation>
<PartnerName>THE MOSAIC COMPANY</PartnerName>
<PartnerIdentifier Agency="GLN">0811875010007</PartnerIdentifier>
</PartnerInformation>
</From>
<To>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATI</PartnerName>
<PartnerIdentifier Agency="GLN">756637000226</PartnerIdentifier>
</PartnerInformation>
</To>
</Header>
<OrderResponseBody>
<OrderResponseProperties>
<PurchaseOrderNumber>
<DocumentIdentifier>OD2314874</DocumentIdentifier>
</PurchaseOrderNumber>
<PurchaseOrderIssuedDate>
<DateTime DateTimeQualifier="On">2009-04-16T09:34:13Z</DateTime>
</PurchaseOrderIssuedDate>
<LanguageCode Domain="ISO-639-2T">EN</LanguageCode>
<CurrencyCode Domain="ISO-4217">USD</CurrencyCode>
<BuyerSequenceNumber>0</BuyerSequenceNumber>
<SellerSequenceNumber>0</SellerSequenceNumber>
<ReferenceInformation ReferenceType="SupplierOrderNumber">
<DocumentReference>
<DocumentIdentifier>1153162</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="ReleaseNumber">
<DocumentReference>
<DocumentIdentifier>OD2314874</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="ContractNumber">
<DocumentReference>
<DocumentIdentifier>40041702</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<TransportMethodCode Domain="UN-Rec-19">2</TransportMethodCode>
<DeliveryTerms>
<DeliveryTermsCode Domain="Incoterms-2000">DDU</DeliveryTermsCode>
<DeliveryTermsLocation>ORIGIN</DeliveryTermsLocation>
</DeliveryTerms>
<ShipmentMethodOfPaymentCode Domain="ANSI-ASC-X12-146">PP</ShipmentMethodOfPaymentCode>
</OrderResponseProperties>
<OrderResponsePartners>
<Buyer>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATI</PartnerName>
<PartnerIdentifier Agency="GLN">756637000226</PartnerIdentifier>
</PartnerInformation>
</Buyer>
<Seller>
<PartnerInformation>
<PartnerName>Bensensville</PartnerName>
<PartnerIdentifier Agency="GLN">811875010298</PartnerIdentifier>
</PartnerInformation>
</Seller>
<ShipTo>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOP, INC.</PartnerName>
<PartnerIdentifier Agency="GLN">756637001766</PartnerIdentifier>
</PartnerInformation>
</ShipTo>
<Payer>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATI</PartnerName>
<PartnerIdentifier Agency="GLN">756637000226</PartnerIdentifier>
</PartnerInformation>
</Payer>
<OtherPartner PartnerRole="ShipFrom">
<PartnerInformation>
<PartnerName>Bensensville</PartnerName>
<PartnerIdentifier Agency="GLN">0811875010298</PartnerIdentifier>
</PartnerInformation>
</OtherPartner>
<OtherPartner PartnerRole="Receiver">
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATIVE, INC.</PartnerName>
<PartnerIdentifier Agency="GLN">0756637000226</PartnerIdentifier>
</PartnerInformation>
</OtherPartner>
</OrderResponsePartners>
<OrderResponseDetails>
<OrderResponseProductLineItem>
<LineNumber>10</LineNumber>
<PurchaseOrderLineItemNumber>000001</PurchaseOrderLineItemNumber>
<ProductIdentification>
<ProductIdentifier Agency="AGIIS-ProductID">90410000003087</ProductIdentifier>
<ProductDescription>First Product</ProductDescription>
</ProductIdentification>
<ReferenceInformation ReferenceType="PurchaseOrderNumber">
<DocumentReference>
<DocumentIdentifier>OD2314874</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="ContractNumber">
<DocumentReference>
<DocumentIdentifier>40041702</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="SupplierOrderNumber">
<DocumentReference>
<DocumentIdentifier>1153162</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ProductQuantity>
<Measurement>
<MeasurementValue>100.000</MeasurementValue>
<UnitOfMeasureCode Domain="UN-Rec-20">STN</UnitOfMeasureCode>
</Measurement>
</ProductQuantity>
<ScheduleLineDetails>
<ScheduleLineIdentifier>001</ScheduleLineIdentifier>
<ProductQuantity>
<Measurement>
<MeasurementValue>100.000</MeasurementValue>
<UnitOfMeasureCode Domain="UN-Rec-20">STN</UnitOfMeasureCode>
</Measurement>
</ProductQuantity>
<ScheduleDateTimeInformation ScheduleType="RequestedShip">
<DateTimeInformation>
<DateTime DateTimeQualifier="OnOrAfter">2009-04-21T20:34:13Z</DateTime>
</DateTimeInformation>
</ScheduleDateTimeInformation>
</ScheduleLineDetails>
<ScheduleDateTimeInformation ScheduleType="RequestedShip">
<DateTimeInformation>
<DateTime DateTimeQualifier="OnOrAfter">2009-04-21T20:34:13Z</DateTime>
</DateTimeInformation>
</ScheduleDateTimeInformation>
<LineStatus>Pending</LineStatus>
<ResponseStatus>
<ResponseStatusReasonIdentifier Agency="RAPIDResponseRejectionTable">099</ResponseStatusReasonIdentifier>
<ResponseStatusReasonDescription>MOSAIC FURTHER PROCESSING REQUIRED</ResponseStatusReasonDescription>
</ResponseStatus>
</OrderResponseProductLineItem>
</OrderResponseDetails>
</OrderResponseBody>
<Header>
<ThisDocumentIdentifier>
<DocumentIdentifier>7269540</DocumentIdentifier>
</ThisDocumentIdentifier>
<ThisDocumentDateTime>
<DateTime DateTimeQualifier="On">2009-04-17T20:34:16Z</DateTime>
</ThisDocumentDateTime>
<From>
<PartnerInformation>
<PartnerName>THE MOSAIC COMPANY</PartnerName>
<PartnerIdentifier Agency="GLN">0811875010007</PartnerIdentifier>
</PartnerInformation>
</From>
<To>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATI</PartnerName>
<PartnerIdentifier Agency="GLN">756637000226</PartnerIdentifier>
</PartnerInformation>
</To>
</Header>
<OrderResponseBody>
<OrderResponseProperties>
<PurchaseOrderNumber>
<DocumentIdentifier>OD2314875</DocumentIdentifier>
</PurchaseOrderNumber>
<PurchaseOrderIssuedDate>
<DateTime DateTimeQualifier="On">2009-04-17T18:34:17Z</DateTime>
</PurchaseOrderIssuedDate>
<LanguageCode Domain="ISO-639-2T">EN</LanguageCode>
<CurrencyCode Domain="ISO-4217">USD</CurrencyCode>
<BuyerSequenceNumber>0</BuyerSequenceNumber>
<SellerSequenceNumber>0</SellerSequenceNumber>
<ReferenceInformation ReferenceType="SupplierOrderNumber">
<DocumentReference>
<DocumentIdentifier>1153163</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="ReleaseNumber">
<DocumentReference>
<DocumentIdentifier>OD2314875</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="ContractNumber">
<DocumentReference>
<DocumentIdentifier>40041702</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<TransportMethodCode Domain="UN-Rec-19">2</TransportMethodCode>
<DeliveryTerms>
<DeliveryTermsCode Domain="Incoterms-2000">DDU</DeliveryTermsCode>
<DeliveryTermsLocation>ORIGIN</DeliveryTermsLocation>
</DeliveryTerms>
<ShipmentMethodOfPaymentCode Domain="ANSI-ASC-X12-146">PP</ShipmentMethodOfPaymentCode>
</OrderResponseProperties>
<OrderResponsePartners>
<Buyer>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATI</PartnerName>
<PartnerIdentifier Agency="GLN">756637000226</PartnerIdentifier>
</PartnerInformation>
</Buyer>
<Seller>
<PartnerInformation>
<PartnerName>Holyoke</PartnerName>
<PartnerIdentifier Agency="GLN">811875010298</PartnerIdentifier>
</PartnerInformation>
</Seller>
<ShipTo>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOP, INC.</PartnerName>
<PartnerIdentifier Agency="GLN">756637001766</PartnerIdentifier>
</PartnerInformation>
</ShipTo>
<Payer>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATI</PartnerName>
<PartnerIdentifier Agency="GLN">756637000226</PartnerIdentifier>
</PartnerInformation>
</Payer>
<OtherPartner PartnerRole="ShipFrom">
<PartnerInformation>
<PartnerName>Mars</PartnerName>
<PartnerIdentifier Agency="GLN">0811875010298</PartnerIdentifier>
</PartnerInformation>
</OtherPartner>
<OtherPartner PartnerRole="Receiver">
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATIVE, INC.</PartnerName>
<PartnerIdentifier Agency="GLN">0756637000226</PartnerIdentifier>
</PartnerInformation>
</OtherPartner>
</OrderResponsePartners>
<OrderResponseDetails>
<OrderResponseProductLineItem>
<LineNumber>10</LineNumber>
<PurchaseOrderLineItemNumber>000001</PurchaseOrderLineItemNumber>
<ProductIdentification>
<ProductIdentifier Agency="AGIIS-ProductID">90410000003087</ProductIdentifier>
<ProductDescription>Second Product</ProductDescription>
</ProductIdentification>
<ReferenceInformation ReferenceType="PurchaseOrderNumber">
<DocumentReference>
<DocumentIdentifier>OD2314875</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="ContractNumber">
<DocumentReference>
<DocumentIdentifier>40041702</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="SupplierOrderNumber">
<DocumentReference>
<DocumentIdentifier>1153163</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ProductQuantity>
<Measurement>
<MeasurementValue>200.000</MeasurementValue>
<UnitOfMeasureCode Domain="UN-Rec-20">STN</UnitOfMeasureCode>
</Measurement>
</ProductQuantity>
<ScheduleLineDetails>
<ScheduleLineIdentifier>001</ScheduleLineIdentifier>
<ProductQuantity>
<Measurement>
<MeasurementValue>200.000</MeasurementValue>
<UnitOfMeasureCode Domain="UN-Rec-20">STN</UnitOfMeasureCode>
</Measurement>
</ProductQuantity>
<ScheduleDateTimeInformation ScheduleType="RequestedShip">
<DateTimeInformation>
<DateTime DateTimeQualifier="OnOrAfter">2009-04-21T20:34:17Z</DateTime>
</DateTimeInformation>
</ScheduleDateTimeInformation>
</ScheduleLineDetails>
<ScheduleDateTimeInformation ScheduleType="RequestedShip">
<DateTimeInformation>
<DateTime DateTimeQualifier="OnOrAfter">2009-04-21T20:34:17Z</DateTime>
</DateTimeInformation>
</ScheduleDateTimeInformation>
<LineStatus>Pending</LineStatus>
<ResponseStatus>
<ResponseStatusReasonIdentifier Agency="RAPIDResponseRejectionTable">099</ResponseStatusReasonIdentifier>
<ResponseStatusReasonDescription>MOSAIC FURTHER PROCESSING REQUIRED</ResponseStatusReasonDescription>
</ResponseStatus>
</OrderResponseProductLineItem>
</OrderResponseDetails>
</OrderResponseBody>
<Header>
<ThisDocumentIdentifier>
<DocumentIdentifier>7267482</DocumentIdentifier>
</ThisDocumentIdentifier>
<ThisDocumentDateTime>
<DateTime DateTimeQualifier="On">2009-04-18T22:34:20Z</DateTime>
</ThisDocumentDateTime>
<From>
<PartnerInformation>
<PartnerName>THE MOSAIC COMPANY</PartnerName>
<PartnerIdentifier Agency="GLN">0811875010007</PartnerIdentifier>
</PartnerInformation>
</From>
<To>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATI</PartnerName>
<PartnerIdentifier Agency="GLN">756637000226</PartnerIdentifier>
</PartnerInformation>
</To>
</Header>
<OrderResponseBody>
<OrderResponseProperties>
<PurchaseOrderNumber>
<DocumentIdentifier>OD2314876</DocumentIdentifier>
</PurchaseOrderNumber>
<PurchaseOrderIssuedDate>
<DateTime DateTimeQualifier="On">2009-04-18T19:34:21Z</DateTime>
</PurchaseOrderIssuedDate>
<LanguageCode Domain="ISO-639-2T">EN</LanguageCode>
<CurrencyCode Domain="ISO-4217">USD</CurrencyCode>
<BuyerSequenceNumber>0</BuyerSequenceNumber>
<SellerSequenceNumber>0</SellerSequenceNumber>
<ReferenceInformation ReferenceType="SupplierOrderNumber">
<DocumentReference>
<DocumentIdentifier>1153164</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="ReleaseNumber">
<DocumentReference>
<DocumentIdentifier>OD2314876</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="ContractNumber">
<DocumentReference>
<DocumentIdentifier>40041702</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<TransportMethodCode Domain="UN-Rec-19">2</TransportMethodCode>
<DeliveryTerms>
<DeliveryTermsCode Domain="Incoterms-2000">DDU</DeliveryTermsCode>
<DeliveryTermsLocation>ORIGIN</DeliveryTermsLocation>
</DeliveryTerms>
<ShipmentMethodOfPaymentCode Domain="ANSI-ASC-X12-146">PP</ShipmentMethodOfPaymentCode>
</OrderResponseProperties>
<OrderResponsePartners>
<Buyer>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATI</PartnerName>
<PartnerIdentifier Agency="GLN">756637000226</PartnerIdentifier>
</PartnerInformation>
</Buyer>
<Seller>
<PartnerInformation>
<PartnerName>Bensensville</PartnerName>
<PartnerIdentifier Agency="GLN">811875010298</PartnerIdentifier>
</PartnerInformation>
</Seller>
<ShipTo>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOP, INC.</PartnerName>
<PartnerIdentifier Agency="GLN">756637001766</PartnerIdentifier>
</PartnerInformation>
</ShipTo>
<Payer>
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATI</PartnerName>
<PartnerIdentifier Agency="GLN">756637000226</PartnerIdentifier>
</PartnerInformation>
</Payer>
<OtherPartner PartnerRole="ShipFrom">
<PartnerInformation>
<PartnerName>Venus</PartnerName>
<PartnerIdentifier Agency="GLN">0811875010298</PartnerIdentifier>
</PartnerInformation>
</OtherPartner>
<OtherPartner PartnerRole="Receiver">
<PartnerInformation>
<PartnerName>SOUTHERN STATES COOPERATIVE, INC.</PartnerName>
<PartnerIdentifier Agency="GLN">0756637000226</PartnerIdentifier>
</PartnerInformation>
</OtherPartner>
</OrderResponsePartners>
<OrderResponseDetails>
<OrderResponseProductLineItem>
<LineNumber>10</LineNumber>
<PurchaseOrderLineItemNumber>000001</PurchaseOrderLineItemNumber>
<ProductIdentification>
<ProductIdentifier Agency="AGIIS-ProductID">90410000003087</ProductIdentifier>
<ProductDescription>Third Product</ProductDescription>
</ProductIdentification>
<ReferenceInformation ReferenceType="PurchaseOrderNumber">
<DocumentReference>
<DocumentIdentifier>OD2314876</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="ContractNumber">
<DocumentReference>
<DocumentIdentifier>40041702</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ReferenceInformation ReferenceType="SupplierOrderNumber">
<DocumentReference>
<DocumentIdentifier>1153164</DocumentIdentifier>
</DocumentReference>
</ReferenceInformation>
<ProductQuantity>
<Measurement>
<MeasurementValue>300.000</MeasurementValue>
<UnitOfMeasureCode Domain="UN-Rec-20">STN</UnitOfMeasureCode>
</Measurement>
</ProductQuantity>
<ScheduleLineDetails>
<ScheduleLineIdentifier>001</ScheduleLineIdentifier>
<ProductQuantity>
<Measurement>
<MeasurementValue>300.000</MeasurementValue>
<UnitOfMeasureCode Domain="UN-Rec-20">STN</UnitOfMeasureCode>
</Measurement>
</ProductQuantity>
<ScheduleDateTimeInformation ScheduleType="RequestedShip">
<DateTimeInformation>
<DateTime DateTimeQualifier="OnOrAfter">2009-04-21T20:34:21Z</DateTime>
</DateTimeInformation>
</ScheduleDateTimeInformation>
</ScheduleLineDetails>
<ScheduleDateTimeInformation ScheduleType="RequestedShip">
<DateTimeInformation>
<DateTime DateTimeQualifier="OnOrAfter">2009-04-21T20:34:21Z</DateTime>
</DateTimeInformation>
</ScheduleDateTimeInformation>
<LineStatus>Pending</LineStatus>
<ResponseStatus>
<ResponseStatusReasonIdentifier Agency="RAPIDResponseRejectionTable">099</ResponseStatusReasonIdentifier>
<ResponseStatusReasonDescription>MOSAIC FURTHER PROCESSING REQUIRED</ResponseStatusReasonDescription>
</ResponseStatus>
</OrderResponseProductLineItem>
</OrderResponseDetails>
</OrderResponseBody>
</
OrderResponse>

 
Old April 23rd, 2009, 01:13 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Surely you could have simplified this a bit? Reducing a problem to its essentials not only makes it easier for other people to help you, it often helps you understand it yourself.

Your stylesheet refers to an element called RequestingDocumentDateTime but there seems to be no such element in your source.

I suspect that following-sibling::*/ThisDocumentDateTime should be following-sibling::Heading[1]/ThisDocumentDateTime, that is you only want the immediately following Heading element, not all subsequent Heading elements (in XSLT you can sometimes get away without the [1] because xsl:value-of, if given a node-set, always chooses the first. But in the case of preceding-sibling this doesn't work, because you'll get the first in document order, not the most recent preceding sibling).

And of course your code could be vastly simplified by using a variable:

<xsl:variable name="Header" select="following-sibling::Header[1]"/>

and then $Header/ThisDocumentDateTime etc.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 23rd, 2009, 01:26 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

A few suggestions:
  • Extract the date parsing logic into a named template that accepts the ISO date time string as a parameter.
  • Change the search to be
    Code:
    preceding-sibling::Header[1]/RequestingDocumentDateTime/DateTime
  • Change the test to be
    Code:
    test="preceding-sibling::Header[1]/RequestingDocumentDateTime/DateTime"
    assuming that if the element is there it won't be empty.
__________________
Joe
http://joe.fawcett.name/
 
Old April 23rd, 2009, 01:35 PM
Registered User
 
Join Date: Apr 2009
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default Thanks Michael - I'll give that a go.

Your suggestion for using following-sibling::Heading[1]/ThisDocumentDateTime makes sense, although there is the possibility that a single XML document may have multiple Header and OrderResponseBody elements.

I haven't had occasion to use xsl:variable, but I'll look at it in more depth.

Thanks Again-

Bob
 
Old April 23rd, 2009, 01:46 PM
Registered User
 
Join Date: Apr 2009
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Thanks Joe -

The named template for the date parsing routine sounds like a REALLY good idea. As I explained to Michael, there is the real possibility of receiving multiple Header and OrderResponseBody nodes within a document since there can be multiple orders within a single document. I'll be taking both your ideas and working with them this afternoon.

Since I have been receiving empty and/or documents with missing elements, you'll see the xsl:otherwise N/A in my code to try and mitigate these issues.

Thanks Again - I've enjoyed chatting with both you Gentlemen!

Bob





Similar Threads
Thread Thread Starter Forum Replies Last Post
SSIS Not pulling data correctly chevy SQL Server 2005 0 February 26th, 2008 04:12 PM
Ajax not pulling back data gmoney BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 August 22nd, 2006 02:31 AM
pulling data from webpage zeeonline XSLT 3 July 27th, 2006 03:04 PM
placeholder controls -- pulling data Fubar ASP.NET 1.0 and 1.1 Professional 6 September 8th, 2005 09:08 AM
Check boxe pulling data Calibus Classic ASP Databases 3 August 7th, 2004 02:11 AM





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