For each in xslt
From the attachment, The 'string' element under the record 'AoIAgeGroups' is set to unbounded.
I am working on xslt, want to loop through every element of string and display as output.
The xslt is as below:
<types:Line>Age Groups:</types:Line>
<xsl:for-each select="s1:AoIAgeGroups/s3:string">
<types:Line><xsl:value-of select="text()"/></types:Line>
</xsl:for-each>
But I am getting only the first element in xml input string. It's not listing everything in it.
The input xml is as below:
<AoIAgeGroups xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<b:string>0-5 years</b:string>
<b:string>6-12 years</b:string>
<b:string>13-24 years</b:string>
<b:string>25-65 years</b:string>
<b:string>65+ years</b:string>
</AoIAgeGroups>
Currently it's listing only the 0-5 years of the input xml string. I want to list out all others so the output will be
0-5 years
6-12 years
13-24 years
25-65 years
65+ years
<?xml version="1.0" encoding="utf-16" ?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0 s1 userCSharp" version="1.0" xmlns:ns0="http://esb/email/2011/01" xmlns:types="http://esb/email/types/2011/01" xmlns:s3="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:s2="http://esb/phrc/1" xmlns:s1="http://esb/registration/1" xmlns:s0="http://esb/shared/1" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp" xmlns:ScriptNS0="http://schemas.microsoft.com/BizTalk/2003/ScriptNS0">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
- <xsl:template match="/">
<xsl:apply-templates select="/s1:Registration" />
</xsl:template>
- <xsl:template match="/s1:Registration">
- <ns0:Plain>
<types:Subject>Form Submission for Registration</types:Subject>
- <types:DeliveryReceipt>
<xsl:text>0</xsl:text>
</types:DeliveryReceipt>
- <types:ReadReceipt>
<xsl:text>0</xsl:text>
</types:ReadReceipt>
- <types:From>
- <xsl:choose>
- <xsl:when test="string-length(s1:PersonalDetails/s0:ContactDetails/s0:EmailAddress/text()) > 0">
- <types:EmailAddress>
<xsl:value-of select="s1:PersonalDetails/s0:ContactDetails/s0:EmailAddress/text()" />
</types:EmailAddress>
</xsl:when>
- <xsl:otherwise>
<xsl:variable name="var:v6" select="ScriptNS0:Read("eFormsV2" , "DefaultCitizenFromEmail")" />
- <types:EmailAddress>
<xsl:value-of select="$var:v6" />
</types:EmailAddress>
</xsl:otherwise>
</xsl:choose>
<types:DisplayName>Form Submission for Registration</types:DisplayName>
</types:From>
- <types:To>
<xsl:variable name="var:v6" select="ScriptNS0:Read("eFormsV2" , "PHRCRegistrationDepartmentEmail")" />
- <types:EmailAddress>
<xsl:value-of select="$var:v6" />
</types:EmailAddress>
</types:To>
<types:Line>The following message has been submitted.</types:Line>
<types:Line />
- <!-- Details collected for all types of membership
-->
<types:Line>Details:</types:Line>
<types:Line />
- <types:Line>
Name:
<xsl:value-of select="s1:PersonalDetails/s0:ContactDetails/s0:Title/text()" />
<xsl:text />
<xsl:value-of select="s1:PersonalDetails/s0:ContactDetails/s0:FirstName/text()" />
<xsl:text />
<xsl:value-of select="s1:PersonalDetails/s0:ContactDetails/s0:Surname/text()" />
</types:Line>
<types:Line />
- <xsl:if test="string-length(s1:PersonalDetails/s0:ContactDetails/s0:EmailAddress/text()) > 0">
- <types:Line>
Email:
<xsl:value-of select="s1:PersonalDetails/s0:ContactDetails/s0:EmailAddress/text()" />
</types:Line>
</xsl:if>
<types:Line />
- <xsl:if test="string-length(s1:PersonalDetails/s0:ContactDetails/s0:MobilePhone/text()) > 0">
- <types:Line>
Mobile Phone:
<xsl:value-of select="s1:PersonalDetails/s0:ContactDetails/s0:MobilePhone/text()" />
</types:Line>
</xsl:if>
<types:Line />
- <types:Line>
Type of Membership:
<xsl:value-of select="s1:TypeOfMembership/text()" />
</types:Line>
<types:Line />
- <!-- Home details only collected for Professionals and students
-->
- <xsl:if test="s1:TypeOfMembership/text() = 'Student' or s1:TypeOfMembership/text() = 'Professional'">
<types:Line />
- <xsl:if test="string-length(s1:PersonalDetails/s0:ContactDetails/s0:HomePhone/text()) > 0">
- <types:Line>
Home Phone:
<xsl:value-of select="s1:PersonalDetails/s0:ContactDetails/s0:HomePhone/text()" />
</types:Line>
<types:Line />
</xsl:if>
<types:Line>Address:</types:Line>
- <xsl:if test="string-length(s1:PersonalDetails/s0:AddressDetails/s0:BusinessName/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:PersonalDetails/s0:AddressDetails/s0:BusinessName/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:PersonalDetails/s0:AddressDetails/s0:HouseName/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:PersonalDetails/s0:AddressDetails/s0:HouseName/text()" />
</types:Line>
</xsl:if>
- <types:Line>
<xsl:value-of select="s1:PersonalDetails/s0:AddressDetails/s0:HouseNumber/text()" />
<xsl:text />
<xsl:value-of select="s1:PersonalDetails/s0:AddressDetails/s0:Street/text()" />
</types:Line>
- <xsl:if test="string-length(s1:PersonalDetails/s0:AddressDetails/s0:Locality/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:PersonalDetails/s0:AddressDetails/s0:Locality/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:PersonalDetails/s0:AddressDetails/s0:Town/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:PersonalDetails/s0:AddressDetails/s0:Town/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:PersonalDetails/s0:AddressDetails/s0:County/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:PersonalDetails/s0:AddressDetails/s0:County/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:PersonalDetails/s0:AddressDetails/s0:PostCode/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:PersonalDetails/s0:AddressDetails/s0:PostCode/text()" />
</types:Line>
</xsl:if>
<types:Line />
</xsl:if>
- <!-- Course Details are only collected for students
-->
<types:Line />
- <xsl:if test="s1:TypeOfMembership/text() = 'Student'">
- <types:Line>
Course Title:
<xsl:value-of select="s1:CourseDetails/s2:CourseTitle/text()" />
</types:Line>
- <xsl:if test="string-length(s1:CourseDetails/s2:Department/text()) > 0">
- <types:Line>
Department:
<xsl:value-of select="s1:CourseDetails/s2:Department/text()" />
</types:Line>
</xsl:if>
- <types:Line>
College / University:
<xsl:value-of select="s1:CourseDetails/s2:EstablishmentName/text()" />
</types:Line>
<types:Line />
<types:Line>College / University Address:</types:Line>
- <xsl:if test="string-length(s1:CourseDetails/s2:Address/s0:BusinessName/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:Address/s0:BusinessName/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:CourseDetails/s2:Address/s0:HouseName/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:Address/s0:HouseName/text()" />
</types:Line>
</xsl:if>
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:Address/s0:HouseNumber/text()" />
<xsl:text />
<xsl:value-of select="s1:CourseDetails/s2:Address/s0:Street/text()" />
</types:Line>
- <xsl:if test="string-length(s1:CourseDetails/s2:Address/s0:Locality/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:Address/s0:Locality/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:CourseDetails/s2:Address/s0:Town/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:Address/s0:Town/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:CourseDetails/s2:Address/s0:County/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:Address/s0:County/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:CourseDetails/s2:Address/s0:PostCode/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:Address/s0:PostCode/text()" />
</types:Line>
</xsl:if>
<types:Line />
- <types:Line>
Tutors contact no.:
<xsl:value-of select="s1:CourseDetails/s2:Tutor/s0:ContactDetails/s0:WorkPhone/text()" />
</types:Line>
<types:Line />
- <types:Line>
Tutors email address:
<xsl:value-of select="s1:CourseDetails/s2:Tutor/s0:ContactDetails/s0:EmailAddress/text()" />
</types:Line>
<types:Line />
<types:Line>Term time address:</types:Line>
- <xsl:if test="string-length(s1:CourseDetails/s2:TermTimeAddress/s0:BusinessName/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:TermTimeAddress/s0:BusinessName/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:CourseDetails/s2:TermTimeAddress/s0:HouseName/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:TermTimeAddress/s0:HouseName/text()" />
</types:Line>
</xsl:if>
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:TermTimeAddress/s0:HouseNumber/text()" />
<xsl:text />
<xsl:value-of select="s1:CourseDetails/s2:TermTimeAddress/s0:Street/text()" />
</types:Line>
- <xsl:if test="string-length(s1:CourseDetails/s2:TermTimeAddress/s0:Locality/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:TermTimeAddress/s0:Locality/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:CourseDetails/s2:TermTimeAddress/s0:Town/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:TermTimeAddress/s0:Town/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:CourseDetails/s2:TermTimeAddress/s0:County/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:TermTimeAddress/s0:County/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:CourseDetails/s2:TermTimeAddress/s0:PostCode/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:CourseDetails/s2:TermTimeAddress/s0:PostCode/text()" />
</types:Line>
</xsl:if>
<types:Line />
</xsl:if>
- <xsl:if test="s1:TypeOfMembership/text() = 'Professional'">
<types:Line />
- <xsl:if test="string-length(s1:ProfessionalDetails/s2:ProfessionalCategory/text()) > 0">
- <types:Line>
Professional Category:
<xsl:value-of select="s1:ProfessionalDetails/s2:ProfessionalCategory/text()" />
</types:Line>
<types:Line />
</xsl:if>
- <types:Line>
Line Managers Name:
<xsl:value-of select="s1:ProfessionalDetails/s2:LineManager/s0:ContactDetails/s0:FirstName/text()" />
</types:Line>
- <xsl:if test="string-length(s1:ProfessionalDetails/s2:LineManager/s0:ContactDetails/s0:WorkPhone/text()) > 0">
- <types:Line>
Line Managers No.:
<xsl:value-of select="s1:ProfessionalDetails/s2:LineManager/s0:ContactDetails/s0:WorkPhone/text()" />
</types:Line>
</xsl:if>
<types:Line />
</xsl:if>
- <!-- Employment details only collected for professional and leaflet members
-->
- <xsl:if test="s1:TypeOfMembership/text() = 'Professional' or s1:TypeOfMembership/text() = 'Only want to order leaflets'">
<types:Line />
- <types:Line>
Job Title:
<xsl:value-of select="s1:ProfessionalDetails/s2:JobTitle/text()" />
</types:Line>
<types:Line />
- <xsl:if test="string-length(s1:ProfessionalDetails/s2:Department/text()) > 0">
- <types:Line>
Department:
<xsl:value-of select="s1:ProfessionalDetails/s2:Department/text()" />
</types:Line>
<types:Line />
</xsl:if>
- <types:Line>
Organisation:
<xsl:value-of select="s1:ProfessionalDetails/s2:Organisation/text()" />
</types:Line>
<types:Line />
<types:Line>Address:</types:Line>
- <xsl:if test="string-length(s1:ProfessionalDetails/s2:Address/s0:BusinessName/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:ProfessionalDetails/s2:Address/s0:BusinessName/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:ProfessionalDetails/s2:Address/s0:HouseName/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:ProfessionalDetails/s2:Address/s0:HouseName/text()" />
</types:Line>
</xsl:if>
- <types:Line>
<xsl:value-of select="s1:ProfessionalDetails/s2:Address/s0:HouseNumber/text()" />
<xsl:text />
<xsl:value-of select="s1:ProfessionalDetails/s2:Address/s0:Street/text()" />
</types:Line>
- <xsl:if test="string-length(s1:ProfessionalDetails/s2:Address/s0:Locality/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:ProfessionalDetails/s2:Address/s0:Locality/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:ProfessionalDetails/s2:Address/s0:Town/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:ProfessionalDetails/s2:Address/s0:Town/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:ProfessionalDetails/s2:Address/s0:County/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:ProfessionalDetails/s2:Address/s0:County/text()" />
</types:Line>
</xsl:if>
- <xsl:if test="string-length(s1:ProfessionalDetails/s2:Address/s0:PostCode/text()) > 0">
- <types:Line>
<xsl:value-of select="s1:ProfessionalDetails/s2:Address/s0:PostCode/text()" />
</types:Line>
</xsl:if>
<types:Line />
- <types:Line>
Work telephone numbers:
<xsl:value-of select="s1:ProfessionalDetails/s2:PhoneNumbers/text()" />
</types:Line>
<types:Line />
</xsl:if>
<types:Line />
- <types:Line>
Confirmation box name:
<xsl:value-of select="s1:AcceptanceName/text()" />
</types:Line>
<types:Line />
<types:Line />
<types:Line>Areas of interest</types:Line>
<types:Line />
<types:Line>Age Groups:</types:Line>
- <xsl:for-each select="s1:AoIAgeGroups/s3:string">
- <types:Line>
<xsl:value-of select="text()" />
</types:Line>
</xsl:for-each>
<types:Line />
<types:Line>Topics:</types:Line>
- <xsl:for-each select="s1:AoITopics/s3:string">
- <types:Line>
<xsl:value-of select="text()" />
</types:Line>
</xsl:for-each>
</ns0:Plain>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8" ?>
- <Registration xmlns="http://esb/registration/1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
- <MetaData xmlns:b="http://esb/shared/1">
<b:UTRN>W86180141692</b:UTRN>
<b:EnquiryType i:nil="true" />
<b:SubType i:nil="true" />
<b:RequestStatus i:nil="true" />
<b:RequestSubStatus i:nil="true" />
<b:CreatedBy i:nil="true" />
<b:Application i:nil="true" />
<b:LGNLCategory i:nil="true" />
<b:FormRef i:nil="true" />
<b:FormVersion i:nil="true" />
<b:ProcessStage i:nil="true" />
<b:CreatedWhen i:nil="true" />
<b:CreatedWhere i:nil="true" />
<b:CreatedHow i:nil="true" />
<b:SentFlag i:nil="true" />
</MetaData>
- <PersonalDetails xmlns:b="http://esb/shared/1">
- <b:ContactDetails>
<b:Title>Mr</b:Title>
<b:FirstName>f</b:FirstName>
<b:Surname>surname</b:Surname>
<b:EmailAddress>[email protected]</b:EmailAddress>
<b:HomePhone />
<b:MobilePhone>m</b:MobilePhone>
<b:WorkPhone i:nil="true" />
<b:Fax i:nil="true" />
<b:Minicom i:nil="true" />
<b:PreferredContact i:nil="true" />
</b:ContactDetails>
- <b:AddressDetails>
<b:FlatUnit />
<b:UPRN>000072532081</b:UPRN>
<b:BusinessName />
<b:HouseName />
<b:HouseNumber>1</b:HouseNumber>
<b:Locality>Woodhouse</b:Locality>
<b:Street>Delph Court</b:Street>
<b:LPILevel />
<b:Town>Leeds</b:Town>
<b:County>Leeds</b:County>
<b:Classification>RD06</b:Classification>
<b:Country>United Kingdom</b:Country>
<b:PostCode>LS6 2HL</b:PostCode>
<b:Ward>Hyde Park and Woodhouse</b:Ward>
</b:AddressDetails>
</PersonalDetails>
- <CourseDetails xmlns:b="http://esb/phrc/1">
<b:CourseTitle />
<b:Department />
<b:EstablishmentName />
- <b:Address xmlns:c="http://esb/shared/1">
<c:FlatUnit />
<c:UPRN i:nil="true" />
<c:BusinessName />
<c:HouseName />
<c:HouseNumber />
<c:Locality />
<c:Street />
<c:LPILevel i:nil="true" />
<c:Town />
<c:County />
<c:Classification i:nil="true" />
<c:Country i:nil="true" />
<c:PostCode />
<c:Ward i:nil="true" />
</b:Address>
- <b:Tutor xmlns:c="http://esb/shared/1">
- <c:ContactDetails>
<c:Title i:nil="true" />
<c:FirstName i:nil="true" />
<c:Surname i:nil="true" />
<c:EmailAddress />
<c:HomePhone i:nil="true" />
<c:MobilePhone i:nil="true" />
<c:WorkPhone />
<c:Fax i:nil="true" />
<c:Minicom i:nil="true" />
<c:PreferredContact i:nil="true" />
</c:ContactDetails>
<c:AddressDetails i:nil="true" />
</b:Tutor>
<b:StudentEmailAddress i:nil="true" />
- <b:TermTimeAddress xmlns:c="http://esb/shared/1">
<c:FlatUnit />
<c:UPRN i:nil="true" />
<c:BusinessName />
<c:HouseName />
<c:HouseNumber />
<c:Locality />
<c:Street />
<c:LPILevel i:nil="true" />
<c:Town />
<c:County />
<c:Classification i:nil="true" />
<c:Country i:nil="true" />
<c:PostCode />
<c:Ward i:nil="true" />
</b:TermTimeAddress>
</CourseDetails>
- <ProfessionalDetails xmlns:b="http://esb/phrc/1">
<b:ProfessionalCategory>Admin/Clerical/Management</b:ProfessionalCategory>
- <b:LineManager xmlns:c="http://esb/shared/1">
- <c:ContactDetails>
<c:Title i:nil="true" />
<c:FirstName>l</c:FirstName>
<c:Surname i:nil="true" />
<c:EmailAddress i:nil="true" />
<c:HomePhone i:nil="true" />
<c:MobilePhone i:nil="true" />
<c:WorkPhone>lmn</c:WorkPhone>
<c:Fax i:nil="true" />
<c:Minicom i:nil="true" />
<c:PreferredContact i:nil="true" />
</c:ContactDetails>
<c:AddressDetails i:nil="true" />
</b:LineManager>
<b:JobTitle>jt</b:JobTitle>
<b:Department>d</b:Department>
<b:Organisation>o</b:Organisation>
- <b:Address xmlns:c="http://esb/shared/1">
<c:FlatUnit />
<c:UPRN>000072532081</c:UPRN>
<c:BusinessName />
<c:HouseName />
<c:HouseNumber>1</c:HouseNumber>
<c:Locality>Woodhouse</c:Locality>
<c:Street>Delph Court</c:Street>
<c:LPILevel />
<c:Town>Leeds</c:Town>
<c:County>Leeds</c:County>
<c:Classification>RD06</c:Classification>
<c:Country>United Kingdom</c:Country>
<c:PostCode>LS6 2HL</c:PostCode>
<c:Ward>Hyde Park and Woodhouse</c:Ward>
</b:Address>
<b:PhoneNumbers>wtn</b:PhoneNumbers>
</ProfessionalDetails>
<TypeOfMembership>Professional</TypeOfMembership>
<WhoToldYou>how did you</WhoToldYou>
<AcceptanceName>please</AcceptanceName>
- <AoIAgeGroups xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<b:string>0-5 years</b:string>
<b:string>6-12 years</b:string>
<b:string>13-24 years</b:string>
<b:string>25-65 years</b:string>
<b:string>65+ years</b:string>
</AoIAgeGroups>
- <AoITopics xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<b:string>Accident prevention</b:string>
<b:string>Healthy eating</b:string>
<b:string>Mental health</b:string>
<b:string>Parenting / Child health</b:string>
<b:string>Physical activity</b:string>
<b:string>Sexual health</b:string>
<b:string>Substance use</b:string>
</AoITopics>
</Registration>
Similar Messages
-
How to use nested for-each in XSLT
Hi all,
This is my sample input xml.
<Conditions>
<Filter operand="AND">
<Filter operand="OR">
<Condition Class="a" Object="b">
<OperandType>Prompt</OperandType>
</Condition>
<Condition Class="Advanced" Object="%">
<OperandType>Prompt</OperandType>
</Condition>
</Filter>
<Condition Class="a" Object="b">
<OperandType>Prompt</OperandType>
</Condition>
<Filter operand="OR">
<Condition Class="Advanced" Object="%">
<OperandType>Prompt</OperandType>
</Condition>
</Filter>
</Filter>
</Conditions>
I want my output as
<sawx:expr xsi:type="sawx:logical" op="and">
<sawx:expr xsi:type="sawx:logical" op="or">
<sawx:expr xsi:type="sawx:special" op="prompted">
<sawx:expr xsi:type="sawx:sqlExpression">"a"."b"</sawx:expr></sawx:expr>
<sawx:expr xsi:type="sawx:special" op="prompted">
<sawx:expr xsi:type="sawx:sqlExpression">"Advanced"."%"</sawx:expr></sawx:expr></sawx:expr>
</sawx:expr>
<sawx:expr xsi:type="sawx:logical" op="or">
<sawx:expr xsi:type="sawx:special" op="prompted">
<sawx:expr xsi:type="sawx:sqlExpression">"a"."b"</sawx:expr>
</sawx:expr>
Can someone tell me how to get this output through xslt?Hi,
Could you please explain the mapping rules between input and ouput?
Also check your output, it's not well-formed. -
Split an XML File and invoke a Web Serivce for each splits using an XSLT
Hi,
We Have a requirement to Split an incoming XML File into chunks based on a child element and hit the target Web Service for each and every split ( i.e no of splits = no of hits on WebService).
Currently, the incoming XML file is getting splitted and gets appended to the SAME Payload and the WebService is hitted only once with the entire Payload.
Is it possible to invoke a WebService within a XSLT ?
Please find below the XSLT code used to split the file in chunks of 3
<xsl:param name="pItemsNumber" select="3"/>
<xsl:template match="@*|node()">
<xsl:choose>
<xsl:when test="count(Batch/Item) > 4">
<ItemMaintenance>
<xsl:for-each-group select="Batch/Item"
group-adjacent="(position()-1) idiv $pItemsNumber">
<xsl:result-document href="ItemsMatch\{current-grouping-key()}.xml">
<ItemMaintenance>
<xsl:copy-of select="current-group()"/>
</ItemMaintenance>
</xsl:result-document>
</xsl:for-each-group>
</ItemMaintenance>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>Hello,
It is possible to invoke a webservice from XSLT. To achieve this you must create a custom XSLT function that does the actual webservice call. You need to write an implementation in Java for this. See my blogpost http://blog.melvinvdkuijl.nl/2010/02/custom-xslt-functions-in-oracle-soa-suite-11g/ for a simple example.
Regards,
Melvin -
How to use for each loop in XSLT when my source is a multilayout file and db
How do I use a for each loop in XSLT when my source is multilayout file and db .
My multilayout file is basically contain 2 kind of data one for employee and another for dependent.
Now my requirement is I want to read each line of data whether it is it is employee or dependent do a join with db and write it in my target file.
eg : File content
1 RichaKumari 311289 TCS INDIA
2 KiarnKumar 456782 BRO RichaKumari 311289 INDIA
2 Ravi 456882 BRO RichaKumari 311289 INDIA
eg : db Content
311289 RichaKumari TCS INDIA Bangalore [email protected]
Now in Final File I need something like this :
1 RichaKumari 311289 TCS INDIA
2 KiarnKumar RichaKumari 311289 TCS INDIA
2 Ravi RichaKumari 311289 TCS INDIA
here 1 and 2 are the identifier which will decide which layout to follow .Hi,
I think you'll need two nested for-each's... Something like...
<xsl:for-each select="$root/row[layout = 1]">
<xsl:variable name="employee" select="."/>
... write employee ...
<xsl:for-each select="$root/row[layout = 2 and dependentid = $employee/id]">
... write dependent ...
</xsl:for-each>
</xsl:for-each>
Cheers,
Vlad -
XSLT for-each within another for-each
Hi All,
My XSLT mapping needs to pick a field(BOL) from the Header and the using that, search the Items node for the matching BOL and generate the output accordingly.
My current XSLT is as follows(not the entire program, just the snippet)
<xsl:for-each select="ns0:Messages/ns0:Message1/ns1:MT_Header/Header">
<xsl:param name="search"><xsl:value-of select="bol"/></xsl:param>
<xsl:for-each select="ns0:Messages/ns0:Message2/ns1:MT_Items/Item[BOL=$search]">
<Output>
<BOL_ITEM><xsl:value-of select="BOL_ITEM"/></BOL_ITEM>
</Output>
</xsl:for-each>
</xsl:for-each>
The following code works correctly(without the outer for-each and with hardcoding)
<xsl:param name="search">100</xsl:param>
<xsl:for-each select="ns0:Messages/ns0:Message2/ns1:MT_Items/Item[BOL=$search]">
<Output>
<BOL_ITEM><xsl:value-of select="BOL_ITEM"/></BOL_ITEM>
</Output>
</xsl:for-each>
So its the for-each within another for-each that does not work . Is there some syntax problem ? Or another way to achieve this in XSLT?Closing this thread
-
Issue with XSLT For each loop in B2B Mapping
Hi All,
I am trying to map the inbound 997 Payload into Headers and Lines Table. I am using the For Each XSLT Construct to map the Loop AK2 of 997 into the 997 Lines Collection.
Issue I am facing is that if the Loop AK2 is repeated for 33 times then for all the 33 times only its first element's value is getting passed into the target of mapping file.
in coming payload
<Loop-AK2>
<Segment-AK2>
<Element-143>810</Element-143>
<Element-329>0001</Element-329>
</Segment-AK2>
<Segment-AK5>
<Element-717>A</Element-717>
</Segment-AK5>
</Loop-AK2>
<Loop-AK2>
<Segment-AK2>
<Element-143>810</Element-143>
<Element-329>0002</Element-329>
</Segment-AK2>
<Segment-AK5>
<Element-717>A</Element-717>
</Segment-AK5>
</Loop-AK2>
<Loop-AK2>
<Segment-AK2>
<Element-143>810</Element-143>
<Element-329>0003</Element-329>
</Segment-AK2>
<Segment-AK5>After transformation using XSLT file the payload looks like as follows
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>33</ns0:lineId>
<ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
<ns0:segmentCode/>
<ns0:segmentPosition/>
<ns0:segmentError/>
<ns0:trxSetAckCode>A</ns0:trxSetAckCode>
</ns0:XxmfiEdi997_AckLines>
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>34</ns0:lineId>
<ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
<ns0:segmentCode/>
<ns0:segmentPosition/>
<ns0:segmentError/>
<ns0:trxSetAckCode>A</ns0:trxSetAckCode>
</ns0:XxmfiEdi997_AckLines>
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>35</ns0:lineId>
<ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
<ns0:segmentCode/>
<ns0:segmentPosition/>
<ns0:segmentError/>
<ns0:trxSetAckCode>A</ns0:trxSetAckCode>
</ns0:XxmfiEdi997_AckLines>
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>36</ns0:lineId>
<ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
<ns0:segmentCode/>
<ns0:segmentPosition/>
<ns0:segmentError/>
<ns0:trxSetAckCode>A</ns0:trxSetAckCode>
</ns0:XxmfiEdi997_AckLines>
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>37</ns0:lineId>
<ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
<ns0:segmentCode/>
<ns0:segmentPosition/>the Element-329 of incoming source payload is mapped to trxSetControlNumber of target payload, the issue is obvious from the above XML data that trxSetControlNumber is always having the value 0001 for every occurence where as its expected to fetch the value of the element of its corresponding occurence not the first elements value.
Please find below the xslt file code i used for mapping
<ns0:XxmfiEdi997_AckHeadersCollection>
<ns0:XxmfiEdi997_AckHeaders>
<ns0:headerId>
<xsl:value-of select='oraext:sequence-next-val("XXMFI_EDI_997_ACK_HEADERS_S","jdbc/MTSI-apps")'/>
</ns0:headerId>
<ns0:processFlag>
<xsl:text disable-output-escaping="no">I</xsl:text>
</ns0:processFlag>
<ns0:xxmfiEdi997_AckLinesCollection>
<xsl:for-each select="/ns1:Transaction-997/ns1:Loop-AK2">
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>
<xsl:value-of select='oraext:sequence-next-val("XXMFI_EDI_997_ACK_LINES_S","jdbc/MTSI-apps")'/>
</ns0:lineId>
<ns0:trxSetIdentCode>
<xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"/>
</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>
<xsl:value-of select="ns1:Segment-AK2/ns1:Element-329"/>
</ns0:trxSetControlNumber>
<ns0:segmentError>
<xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Loop-AK3/ns1:Segment-AK3/ns1:Element-720"/>
</ns0:segmentError>
<ns0:trxSetAckCode>
<xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK5/ns1:Element-717"/>
</ns0:trxSetAckCode>
</ns0:XxmfiEdi997_AckLines>
</xsl:for-each>
</ns0:xxmfiEdi997_AckLinesCollection>
</ns0:XxmfiEdi997_AckHeaders>Is there something I am doing wrong in mapping or am I missing something here. Please suggest .
Thanks in advance
~TK.Hi,
In your xslt code within the for loop, for the trxSetIdentCode why are you using the xpath "/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"? It should be just "ns1:Segment-AK2/ns1:Element-143". Similar changes for segmentError and trxSetAckCode also should be done. Remove the '/ns1:Transaction-997/ns1:Loop-AK2/' part from your xpath expressions inside the for loop and try it.
Sahay -
For Each example using XSLT in BPEL
I need a sample How to use For Each in BPEL using XSLT. Like I am getting an array and need to iterate the target XSD accordingly.
Thanksstart reading this:
http://www.w3schools.com/xsl/xsl_for_each.asp
after that read this:
http://download.oracle.com/docs/cd/E21764_01/integration.1111/e10224/bp_xslt_mpr.htm#BABGJIGI
Regards,
Melvin -
Hi All,
I have a below requirement:
two source nodes:
<NODE1>
<NODE2>
Here node 2 is optional. i want to check if node 2 is present, if it is present then for-each value of node 2
if not the the for each must be based on the value of the parent node which is node1.
Can anyone help me out on this..
Thanks in Advance!Hi,
In your xslt code within the for loop, for the trxSetIdentCode why are you using the xpath "/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"? It should be just "ns1:Segment-AK2/ns1:Element-143". Similar changes for segmentError and trxSetAckCode also should be done. Remove the '/ns1:Transaction-997/ns1:Loop-AK2/' part from your xpath expressions inside the for loop and try it.
Sahay -
XSLT construct "for each" not working in transformation
Hi everyone I am using for each inside a transformation it was working fine until added parameters.After included parameters "for each" is not happening the db is invoked only once even if there are muliple nodes.
can anyone help me on this issue. How to perform for each if paramaters are includedThis is the transform I am using the element used for for each is of unbounded type (typens:getRoutingAndFrameJumpersResponse/typens:oServFrmJmprInfo/typens:oFrmJmpr/typens:item)
<?xml version="1.0" encoding="UTF-8" ?>
<?oracle-xsl-mapper
<!-- SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY. -->
<mapSources>
<source type="WSDL">
<schema location="x.wsdl"/>
<rootElement name="getRoutingAndFrameJumpersResponse" namespace="x.NetworkInstallations"/>
</source>
</mapSources>
<mapTargets>
<target type="XSD">
<schema location="IROBO_PR_UPDATE_INSERT_JUMPER_INFO.xsd"/>
<rootElement name="InputParameters" namespace="http://xmlns.oracle.com/pcbpel/adapter/db/IROBO/PR_UPDATE_INSERT_JUMPER_INFO/"/>
</target>
</mapTargets>
<!-- GENERATED BY ORACLE XSL MAPPER 10.1.3.3.0(build 070615.0525) AT [TUE MAY 19 09:16:31 GMT+05:30 2009]. -->
?>
<xsl:stylesheet version="1.0"
xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:ehdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.headers.ESBHeaderFunctions"
xmlns:typens="x.NetworkInstallations"
xmlns:ns0="http://www.w3.org/2001/XMLSchema"
xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/IROBO/PR_UPDATE_INSERT_JUMPER_INFO/"
xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ora="http://schemas.oracle.com/xpath/extension"
xmlns:wsdlns="http://y.com/WSAI/STAA/"
xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
exclude-result-prefixes="xsl wsdl typens ns0 soap wsdlns db bpws ehdr hwf xp20 xref ora ids orcl">
<xsl:param name="MigrationId"/>
<xsl:param name="LineNumber"/>
<xsl:param name="DN"/>
<xsl:template match="/">
<xsl:for-each select=*"/typens:getRoutingAndFrameJumpersResponse/typens:oServFrmJmprInfo/typens:oFrmJmpr/typens:item"*>
<db:InputParameters>
<db:P_MIGRATION_ID>
<xsl:value-of select="$MigrationId"/>
</db:P_MIGRATION_ID>
<db:CCT_ID>
<xsl:value-of select="$DN"/>
</db:CCT_ID>
<db:FROM__FRAME_TERM_ID>
<xsl:value-of select="typens:frameTermID1"/>
</db:FROM__FRAME_TERM_ID>
<db:FROM_EXTRA>
<xsl:value-of select="typens:reformattedTermID1"/>
</db:FROM_EXTRA>
<db:FROM_MAP>
<xsl:value-of select="typens:locationIn"/>
</db:FROM_MAP>
<db:TO_FRAME_TERM_ID>
<xsl:value-of select="typens:frameTermID2"/>
</db:TO_FRAME_TERM_ID>
<db:TO_EXTRA>
<xsl:value-of select="typens:reformattedTermID2"/>
</db:TO_EXTRA>
<db:TO_MAP>
<xsl:value-of select="typens:locationOut"/>
</db:TO_MAP>
<db:TRANSACTION_ID>
<xsl:value-of select='substring-after(../../../typens:e2EData,"q=")'/>
</db:TRANSACTION_ID>
<db:SEQ_NO>
<xsl:value-of select="position()"/>
</db:SEQ_NO>
<db:LINE_NO>
<xsl:value-of select="$LineNumber"/>
</db:LINE_NO>
</db:InputParameters>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet> -
XSLT For-Each Issue, how to traverse back to previous node
How to get the SupplierName(Primary) from the below payload
*+<ItemSupplier>+*
+<SupplierParty>+
+<SupplierName>SUPPLIER NAME 1</SupplierName>+
+</SupplierParty>+
+<ItemSupplierLocation>+
+<Status>1</Status>+
+<PriorityCode>N</PriorityCode>+
+</ItemSupplierLocation>+
+<ItemSupplierLocation>+
+<Status>2</Status>+
+<PriorityCode>N</PriorityCode>+
+</ItemSupplierLocation>+
*+</ItemSupplier>+*
*+<ItemSupplier>+*
+<SupplierParty>+
*+<SupplierName>SUPPLIER NAME 2</SupplierName>+*
+</SupplierParty>+
+<ItemSupplierLocation>+
+<Status>1</Status>+
+<PriorityCode>N</PriorityCode>+
+</ItemSupplierLocation>+
+<ItemSupplierLocation>+
+<Status>1</Status>+
+<PriorityCode>Y</PriorityCode>+
+</ItemSupplierLocation>+
*+</ItemSupplier>+*
The condition i need to run is as below, but as the control will be inside the <ItemSupplierLocation> how do i go back to previous node and get the value of supplier name.
+<ItemSupplier> can be n number+
<xsl:for-each select="ItemSupplier/ItemSupplierLocation">
<xsl:choose>
<xsl:when test='PriorityCode="Y" and Status="1"'>
<Supplier>
<xsl:value-of select="ItemSupplier/SupplierName"/>
</Supplier>
</xsl:when>
</xsl:choose>
</xsl:for-each>
Thanks,
VijayFixed the issue with the below code
<xsl:for-each select="ItemSupplier/ItemSupplierLocation">
<xsl:choose>
<xsl:when test='PriorityCode="Y" and Status="1"'>
<Supplier>
<xsl:value-of select="../SupplierParty/SupplierName"/>
</Supplier>
</xsl:when>
</xsl:choose>
</xsl:for-each>
Thanks,
Vijay -
How to use For-Each Structure with Multiple node XML structure
Hi,
How to use for-each (BPEL 2.0) construct for Multinode XML structure.
Here is the easy case: I have list of suppliers specified by supplier
<supplierList>
<supplier>1</supplier>
<supplier>2</supplier>
<supplier>3</supplier>
</supplierList>
Now there is a web service http://hostname/getsupplierdetails/wsdl which accepts one supplier at a time.
like
<supplier>1</supplier>
reponse object is
<message> notfound/found </message>
But how can I use for each of XML node to call this service and collect the result like
<supplierList1>
<Suppinfo>
<supplier>1</supplier>
<message> not found</message>
</suppinfo>
<suppinfo>
<supplier>1</supplier>
<message> not found</message>
</suppinfo>
</supplierlist1>
ThanksFor looping you use foreach loop and , loop for the number of occurences and when constructing response, adding a new element you have to use bpelx:append. Good sample at Enterprise Integration: Oracle SOA Suite 11g: Populating a list or an array in BPEL without using XSLT.
-
Using the XSLT processor for non-workbench XSLT
Hi there,
is it possible to use the built-in XSLT processor for arbitrary XSLT transformations which aren't checked in in the ABAP workbench but instead given as a runtime object (string or iXML)?
Instead of the built-in command CALL TRANSFORMATION which according to the doc is restricted to workbench transformations, I am looking for an option like this:
data: lo_transformation type ref to if_ixml_document,
lo_source type ref to if_ixml_document,
lo_target type ref to if_ixml_focument.
* I get lo_transformation and lo_source from somewhere out there
try.
lo_target ?= cl_some_fine_class_which_i_am_looking_for=>transform(
io_source = lo_source
io_transformation = lo_transformation ).
catch cx_xslt_runtime_error.
endtry.
Does anybody know such a feature?
For a background about this problem - in German language - see my blog
http://ruediger-plantiko.blogspot.com/2007/08/xslt-in-bsp-anwendungen-und-in-abap.html
Thanks and Regards,
RüdigerDear Rashid,
thanks - this is the answer! I wonder why I didn't find this class one year ago. A little test prog shows that it works fine and even performant (about 0.5 millisec for creating the new dynamic XSLT program with the method set_source_stream( ) ). For usage in web apps, it would be nice to know whether the temporary program remains available in the application servers' buffer after end of process. I can't check this, since this is performed on the C/C++ level, and SE30 doesn't track the method set_source_stream() itself (it could show a decrease of runtime after the first call).
Here comes a little self-contained ABAP program to test the functionality. It works well on our system with SAPKB70012.
Thanks and regards,
Rüdiger
* --- Test usage of a dynamically given non-workbench XSLT program
report zz_test_cl_xslt_processor.
data:
* iXML master
go_xml type ref to if_ixml,
* iXML stream factory
go_sf type ref to if_ixml_stream_factory.
load-of-program.
go_xml = cl_ixml=>create( ).
go_sf = go_xml->create_stream_factory( ).
start-of-selection.
perform start.
* --- Start
form start.
data: lo_source type ref to if_ixml_document,
lo_result type ref to if_ixml_document,
lo_processor type ref to cl_xslt_processor,
lv_p type progname,
lo_ex type ref to cx_xslt_exception.
perform get_source changing lo_source.
create object lo_processor.
try.
* Set source
lo_processor->set_source_node( lo_source ).
* Set result
lo_result = go_xml->create_document( ).
lo_processor->set_result_document( lo_result ).
* This could be time-critical, the creation of a dynamical XSLT prog?
perform set_transformation using lo_processor
changing lv_p.
* call xslt-proc
lo_processor->run( lv_p ).
* Display result
call function 'SDIXML_DOM_TO_SCREEN'
exporting
document = lo_result
title = 'Result of Transformation'
exceptions
no_document = 1
others = 2.
catch cx_xslt_exception into lo_ex.
sy-msgli = lo_ex->get_text( ).
message sy-msgli type 'I'.
endtry.
endform. "start
* --- Set XSLT transformation from stream
form set_transformation using io_processor type ref to cl_xslt_processor
changing cv_p type progname.
data: lo_trans type ref to if_ixml_istream.
* sv_p contains temp. name of XSLT program after first call
statics: sv_p type string.
if sv_p is initial.
* It seems that the name can be buffered on appserver level?
import progname to sv_p
from shared buffer indx(zx) id 'ZZ_TEST_XSLT_PROC'.
if sv_p is initial.
sv_p = 'X'.
endif.
endif.
* Provide the stream containing the XSLT document (as a stream)
perform get_transformation changing lo_trans.
* Set transformation
io_processor->set_source_stream( exporting stream = lo_trans
changing p = sv_p ).
* Buffer progname on server - seems to work
export progname from sv_p
to shared buffer indx(zx) id 'ZZ_TEST_XSLT_PROC'.
* string -> c move necessary, since xslt-proc-interface doesn't use
* the generic type csequence for program name
cv_p = sv_p.
endform. "set_transformation
* --- Parse a source given as string into an if_ixml_document
form get_source changing co_src type ref to if_ixml_document.
data: lv_s type string,
lo_stream type ref to if_ixml_istream,
lo_parser type ref to if_ixml_parser.
concatenate
`<?xml version="1.0" encoding="iso-8859-1"?>`
`<countings filiale="2412" invnu="TIEFKUEHL SEPT.07">`
`<count recNum="1" gid="1" ean="59111828843" menge="1"`
`preis="0" recNumFrom="1"></count>`
`</countings>`
into lv_s.
* Eingabestream erzeugen und in if_ixml_document abbilden
lo_stream = go_sf->create_istream_string( lv_s ).
co_src = go_xml->create_document( ).
lo_parser = go_xml->create_parser( document = co_src
istream = lo_stream
stream_factory = go_sf ).
lo_parser->parse( ).
endform. "get_source
* --- Put the transformation given as string into an if_ixml_istrean
form get_transformation changing co_trans type ref to if_ixml_istream.
data: lv_s type string.
concatenate
`<?xml version="1.0" encoding="iso-8859-1"?>`
`<xsl:transform version="1.0"`
` xmlns:xsl="http://www.w3.org/1999/XSL/Transform"`
` xmlns:asx="http://www.sap.com/abapxml">`
`<xsl:strip-space elements="*"></xsl:strip-space>`
`<xsl:template match="countings">`
` <asx:abap>`
` <asx:values>`
` <SELOPT>`
` <WERKS><xsl:value-of select="@filiale"></xsl:value-of></WERKS>`
` <INVNU><xsl:value-of select="@invnu"></xsl:value-of></INVNU>`
` </SELOPT>`
` <COUNTINGS>`
` <xsl:for-each select="count">`
` <ZSRS_ZWSTI_LINE>`
` <MATNR></MATNR>`
` <EAN11><xsl:value-of select="@ean"></xsl:value-of></EAN11>`
` <MAKTX></MAKTX>`
` <MENGE><xsl:value-of select="@menge"></xsl:value-of></MENGE>`
` <MEINH></MEINH>`
` <UNAME></UNAME>`
` <EXVKW></EXVKW>`
` <WAERS></WAERS>`
` <FF></FF>`
` <GID><xsl:value-of select="@gid"></xsl:value-of></GID>`
` <RECNUM><xsl:value-of select="@recNum"></xsl:value-of></RECNUM>`
` <RECNUM_FROM><xsl:value-of select="@recNumFrom"></xsl:value-of></RECNUM_FROM>`
` <REF_RECNUM><xsl:value-of select="@refRecNum"></xsl:value-of></REF_RECNUM>`
` </ZSRS_ZWSTI_LINE>`
` </xsl:for-each>`
` </COUNTINGS>`
` </asx:values>`
` </asx:abap>`
`</xsl:template>`
`</xsl:transform>`
into lv_s.
co_trans = go_sf->create_istream_string( lv_s ).
endform. "get_transformation
Edited by: Rüdiger Plantiko on Jul 4, 2008 10:25 AM -
Hello all. I am studying XSLT in school and need some help.
Display the following: Software titles for each operating system sorted by category. Sorting is not the problem. I am having an issue with displaying software titles for each operating system. Here is the XML and the XSLT.
<?xml version="1.0"?>
<!-- Note: For many of the wonders, the experts do not agree on precise dates or construction dimensions. In these cases, I chose a year or dimension in the middle of the range so all attributes could be numeric. -->
<software_inventory>
<software xmlns:xsi="Software.xsd">
<title>Adobe Photoshop</title>
<vendor>Adobe</vendor>
<category>Graphics</category>
<support_platforms>
<Platform>Windows 7</Platform>
<Platform>Windows 8</Platform>
<Platform>Windows 8.1</Platform>
</support_platforms>
<Approved_Versions>
<Version Hardware_Requirements="4GB Ram 2GB Hard Drive" Software_Requiremnts="32/64 bit" Price="399">CS 5.5</Version>
</Approved_Versions>
</software>
<software>
<title>Winzip</title>
<vendor>Winzip International</vendor>
<category>Utility</category>
<support_platforms>
<platform>Windows Vista</platform>
<platform>Windows 7</platform>
<platform>Windows 8</platform>
<platform>Windows 8.1</platform>
</support_platforms>
<Approved_Versions>
<Version Hardware_Requirements="2GB Ram 250MB Hard Drive" Software_Requiremnts="32/64 bit" Price="29.99">19</Version>
</Approved_Versions>
</software>
There are more titles in the XML, but I didn't include them.
Here is the XSLT
<h1>Software Titles for each operating system, sorted by category</h1>
<table border="1">
<tr>
<th>Software Title</th>
<th>Operating System</th>
<th>Category</th>
</tr>
<xsl:for-each select="software_inventory/software">
<xsl:sort select="support_platforms/platform"/>
<xsl:sort select="category"/>
<tr>
<td>
<xsl:value-of select="title"/>
</td>
<td>
<xsl:for-each select="support_platforms/platform">
<xsl:value-of select="platform"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</td>
<td>
<xsl:value-of select="category"/>
</td>
</tr>
</xsl:for-each>
</table>
Here is a screen shot of the output. What I would like is for each Platform / operating system to show in the same cell, so the adjacent cells will grow taller to accommodate.
What am I doing wrong?You cannot ask for "platform" when your pointer is already pointing at "platform".
Also your input XML is inconsistent concerning capitalized and not capitalized "platform/Platform".
Under the assumption that platform should always be "platform", try replacing:
<td>
<xsl:for-each select="support_platforms/platform">
<xsl:value-of select="platform"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</td>
With:
<td>
<xsl:for-each select="support_platforms/platform">
<xsl:value-of select="."/>
<xsl:text> </xsl:text>
</xsl:for-each>
</td>
Morten la Cour -
All,
version:11.1.1.4
I have a requirement in the for-loop which has to iterate for a fixed loop. For instance: I want the for-loop to iterate only for 5 times, how should I define the for-loop? Any idea, please share your thoughts.
<xsl:for-each select="5">
</xsl:for-each>
I tried the above code, didn't work!.
Rgds
senYou can use templates in xslt like one below :- Assign max - 5 and this will loop for 5 times.
<xsl:template name="loop">
<!--recursive loop until done-->
<xsl:param name="i"/>
<xsl:param name="max"/>
<xsl:if test="$i <= $max">
<!-- Repeated content Here -->
<!-- use value-of i to get loop index -->
<xsl:value-of select="$i"/>.<br/>
<xsl:call-template name="loop">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="max" select="$max"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:call-template name="loop">
<xsl:with-param name="i" select="number(1)"/>
<xsl:with-param name="max" select="number(5)"/>
</xsl:call-template>
Or you can also do while loop like one below:-
<!-- recursive named template -->
<xsl:template name="while">
<xsl:variable name="VALUE">
<!-- your evaluation -->
</xsl:variable>
<!-- evaluate and recurse -->
<xsl:if test="$VALUE=0">
<xsl:call-template name="while"/>
</xsl:if>
</xsl:template> -
Hello Everyone,
Please assist with a step by step guide on how to setup a For Each Loop for XML Task
I'm trying to convert XML to XSLT
I have tried more than 10 times and i just do not know what i am doing wrong - no error, my package just runs for a few seconds but nothing happens
Thanks in advance
DeeI managed to get my XML to XSLT to work but now when i run my package to import the data into SQL table,
it stops after a few records, i get the following error:
[XML Source [1]] Error: The component "XML Source" (1) was unable to process the XML data. The element "Errors" cannot contain a child element. Content model is text only.
Please assist
Check this:
http://social.msdn.microsoft.com/Forums/en-US/80726e0c-9e85-43ca-87bc-7cf90fd7fb31/xml-source-data-flow-throws-cannot-contain-a-child-element-content-model-is-text-only-error?forum=sqlintegrationservices
Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
The climb is all there is.
Maybe you are looking for
-
F4 help button not getting displayed
Hi, I have unique problem it seems. I have atttached a explicit search help object for one of the fields in a local structure of type db table.. In standard selection screen i am defining a parameter of this field and have used "matchcode object" als
-
How do you have multiple apple id's with one itunes
how do you have multiple apple id's with one itunes
-
I can't Activate Facetime on iOS 8.1
I recently upgrade my iPad 2 to 8.1 but every time I try to sign-in to FaceTime I get the following error message "Could not sign in. Please check network connection and try again" or "An error occurred during activation. Try again"
-
Hi all, I have been trying to generate a web service from a WSDL file (which, in my opinion, is the best way to create a web service when you don't already have a program). But there's some problems I run across which I can't seem to find the solutio
-
Hallo, I have a realy strange problem. After some time my PowerMac was going in to sleep state. No problem so far. After I woke it up (normal keypress) the graphic was compleatly distorted. I can barely see the windows and the colors are compleatly w