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 September 4th, 2008, 07:19 AM
Authorized User
 
Join Date: Feb 2008
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default I want to retrive PurchaseOrderNumber attribute

Hi,

I am using XSLT 1.0.

I want to loop through list of InvoiceLines(here there are 1 InvoiceLine each in 2 InvoicePurchaseOrder node) and for each InvoiceLine, i want to retrieve the InvoicePurchaseOrderNumber.

Code:
<InvoicePurchaseOrderSet Count="1">
      <InvoicePurchaseOrder PurchaseOrderId="173675" PurchaseOrderNumber="10074841" PurchaseOrderRevision="">
      <InvoiceLineSet Count="1">
          <InvoiceLine InvoiceLineId="85093" ItemType="LINE" LineId="0003" OrderSequence="1" Key1="173675-A-23040-M-095" ItemDescription="STANDARD" Quantity="24" QuantityUOM="PRS" UnitPrice="18.15" Amount1="435.6" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="173675" Attribute2="M" Attribute3="FLORENTINE" Attribute4="23040" Attribute5="BLACK" Attribute6="095" Attribute7="24" Attribute8="12" Attribute9="2" Attribute10="A" Attribute11="10074841" />
      </InvoiceLineSet>
     </InvoicePurchaseOrder>

 <InvoicePurchaseOrder PurchaseOrderId="173676" PurchaseOrderNumber="10074842" PurchaseOrderRevision="">
        <InvoiceLineSet Count="1">
          <InvoiceLine InvoiceLineId="85098" ItemType="LINE" LineId="0003" OrderSequence="1" 
                       Key1="173675-A-23040-M-095" ItemDescription="STANDARD" Quantity="24" QuantityUOM="PRS" 
            UnitPrice="18.15" Amount1="435.6" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" 
            TariffCode="" Attribute1="173675" Attribute2="M" Attribute3="FLORENTINE" Attribute4="23040" 
            Attribute5="BLACK" Attribute6="095" Attribute7="24" Attribute8="12" Attribute9="2" Attribute10="A"
            Attribute11="10074841" />
       </InvoiceLineSet>
      </InvoicePurchaseOrder>
</InvoicePurchaseOrderSet>


 
Old September 4th, 2008, 07:47 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

There is no InvoicePurchaseOrderNumber attribute on the InvoiceLine element.

To 'retrieve' an attribute you simply use the "@" symbol before the attribute name, e.g. @InvoiceLineId.

/- Sam Judson : Wrox Technical Editor -/
 
Old September 4th, 2008, 08:17 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If InvoicePurchaseOrderNumber were an attribute of InvoiceLine, you would do

<xsl:template match="InvoicePurchaseOrder">
<xsl:for-each select="InvoiceLine">
  <xsl:value-of select="@InvoicePurchaseOrderNumber"/>
</xsl:for-each>
</xsl:template>

But it isn't, so I don't really know what you want. Perhaps

<xsl:template match="InvoicePurchaseOrder">
  <xsl:variable name="PO-nr" select="@PurchaseOrderNumber"/>
  <xsl:for-each select="InvoiceLine">
    <xsl:value-of select="$PO-Nr"/>
  </xsl:for-each>
</xsl:template>

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
retrive images from a database vindya0121 VB Databases Basics 0 March 23rd, 2006 07:30 AM
retrive file extension Dj Kat Javascript How-To 2 December 10th, 2005 01:35 PM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM
how to retrive the column properties harshagowda Access 1 December 3rd, 2004 12:13 PM
How do i retrive login name drachx General .NET 6 October 7th, 2004 07:35 PM





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