[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Looping within XSL

Subject: Re: Looping within XSL
From: Kamal Bhatt <kbhatt@xxxxxxxxx>
Date: Fri, 17 Mar 2006 10:18:49 +1100
select xsl
Firstly, I would recommend having another look at your xslt documentation. "Looping" in the traditional sense does not happen in XSLT. Secondly, you are misusing the attribute node. The '=' is not needed.
Manisha Gore wrote:


Hello,

I am trying to generate xml file which will looks like this

<RPSL_BATCH>
<RPSL_PTNR  />
...
<RPSL_PTNR  />
</RPSL_BATCH>

where RPSL_PTNR is as follows

<RPSL_PTNR
ptnr_id="PTNR1"
ptnr_type="SHIP_TO_PARTNER"
sub_org="100"
name_1="NAME"
address_1="ADD1"
address_2="ADD2"
address_3="ADD3"
address_4="ADD4"
address_5="ADD5"
city="CITY"
state_name="STATE"
state_code="STATE_CODE"
postal_code="POSTAL"
ctry_name="CTRY"
ctry_code="CTRY_CODE"
decision=Y
rpl_ind=C
epci_ind=Y
antiboycott_ind=Y
usembargo_ind=Y
unembargo_ind=Y
euembargo_ind=Y
proscribed_ind=Y
user_varchar1="TRANSACTION_ID"
user_varchar2="GEOGRAPHICAL_LOCATION"
user_varchar3="TIME_SUBMITTED"/>

Basically I need to have one RPSL_PTNR for say ship to custoemr and one for
bill to and ione for end user custoemrs etc. I will have those many
RPSL_PTNR repeating in the main batch.


I have come up with the xsl file which looks like

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!-- -->
<!-- Template Output is XML -->
<!-- -->
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"
omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:element name="RPSL_BATCH">
<xsl:apply-templates select="/ORDER"/>
<xsl:apply-templates select="/ORDER/PARTNER"/>
<xsl:for-each select="/ORDER/PARTNER/PARTNER_ROW">
<xsl:element name="RPSL_PTNR">
<!--- BEGIN PARTNER -->
<xsl:attribute name="ptnr_id=">
<xsl:value-of select="/ORDER/PARTNER/CUSTOMER_NUMBER"/>
</xsl:attribute>
<xsl:attribute name="ptnr_type=">
<xsl:value-of select="/ORDER/PARTNER/SITE_USE_CODE"/>
</xsl:attribute>
<xsl:attribute name="sub_org=">
<xsl:value-of select="/ORDER/PARTNER/SUB_ORG"/>
</xsl:attribute>
<xsl:attribute name="app_id=">
<xsl:value-of select="/ORDER/PARTNER/APP_ID"/>
</xsl:attribute>
<xsl:attribute name="name_1=">
<xsl:value-of select="/ORDER/PARTNER/CUSTOMER_NAME"/>
</xsl:attribute>
<xsl:attribute name="address_1=">
<xsl:value-of select="/ORDER/PARTNER/ADDRESS_1"/>
</xsl:attribute>
<xsl:attribute name="address_2=">
<xsl:value-of select="/ORDER/PARTNER/ADDRESS_2"/>
</xsl:attribute>
<xsl:attribute name="address_3=">
<xsl:value-of select="/ORDER/PARTNER/ADDRESS_3"/>
</xsl:attribute>
<xsl:attribute name="address_4=">
<xsl:value-of select="/ORDER/PARTNER/ADDRESS_4"/>
</xsl:attribute>
<xsl:attribute name="address_5=">
<xsl:value-of select="/ORDER/PARTNER/ADDRESS_5"/>
</xsl:attribute>
<xsl:attribute name="city=">
<xsl:value-of select="/ORDER/PARTNER/CITY"/>
</xsl:attribute>
<xsl:attribute name="state_name=">
<xsl:value-of select="/ORDER/PARTNER/STATE_NAME"/>
</xsl:attribute>
<xsl:attribute name="state_code=">
<xsl:value-of select="/ORDER/PARTNER/STATE_CODE"/>
</xsl:attribute>
<xsl:attribute name="postal_code=">
<xsl:value-of select="/ORDER/PARTNER/POSTAL_CODE"/>
</xsl:attribute>
<xsl:attribute name="ctry_name=">
<xsl:value-of select="/ORDER/PARTNER/CTRY_NAME"/>
</xsl:attribute>
<xsl:attribute name="ctry_code=">
<xsl:value-of select="/ORDER/PARTNER/CTRY_CODE"/>
</xsl:attribute>
<xsl:attribute name="created_by=">
<xsl:value-of select="/ORDER/PARTNER/CREATED_BY"/>
</xsl:attribute>
<xsl:attribute name="request_url=">
<xsl:value-of select="/ORDER/PARTNER/REQUEST_URL"/>
</xsl:attribute>
<xsl:attribute name="use_cached_result=">
<xsl:value-of select="/ORDER/PARTNER/USER_CACHED_RESULT"/>
</xsl:attribute>
<xsl:attribute name="persist=">
<xsl:value-of select="/ORDER/PARTNER/PERSIST"/>
</xsl:attribute>
<xsl:attribute name="user_varchar1=">
<xsl:value-of select="./ORDER/ORDER_NUMBER"/>
</xsl:attribute>
<xsl:attribute name="user_varchar2=">
<xsl:value-of select="/ORDER/PARTNER/SITE_USE_ID"/>
</xsl:attribute>
<xsl:attribute name="user_varchar3=">
<xsl:value-of select="/ORDER/PARTNER/USER"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>



What am I doing wrong here. I get error saying not all variables bound.

I am using oralce utl_http to create the XML file.

Thanks,
Manisha




--
Kamal Bhatt

Tourism Technology Pty Ltd


T: +61 (02) 9956 7300 F: +61 (02) 9956 7411


Level 10, 1 Pacific Highway, North Sydney, NSW 2060



http://www.tt.com.au



-- Disclaimer: This email is confidential and may contain privileged information for the sole use of the person or business to which it is addressed. If you are not the intended recipient, please notify the sender by return e-mail or phone as you must not view, disseminate, distribute or copy this email without our consent. We do not accept any liability in connection with any computer virus, data corruption, incompleteness, or unauthorised amendment of this email. It is the sole responsibility of the receiver to scan for viruses before opening.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.