XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Khalid AnsariSubject: Grouping on lookup values.
Author: Khalid Ansari
Date: 18 Sep 2007 01:15 PM
I have a lookup table which contains both description and filed names.
<Codes>
<Code>
<ErrorCodes>Erro1</ErrorCodes>
<Description>Invalid action indicator</Description>
<Field>actionIndicator</Field>
</Code>
<Code>
<ErrorCodes>Error2</ErrorCodes>
<Description>Invalid User</Description>
<Field>userName</Field>
</Code>

....
</Codes>

I process following xml with the above lookup document.


<ErrorGroup>
<row>
<SystemError>
<ErrorCode>Error1</ErrorCode>
</SystemError>
</row>
<row>
<SystemError>
<ErrorCode>Error2</ErrorCode>
</SystemError>
</row>
<row>
<SystemError>
<ErrorCode>Error3</ErrorCode>
</SystemError>
</row>
</ErrorGroup>


and following is my xsl

<xsl:key name="code-lookup" match="Code" use="ErrorCodes"/>
<xsl:variable name="codes-top" select="document("codes.xml")/Codes"/>

<xsl:template match="SystemError">
<xsl:text> Error : </xsl:text> <xsl:value-of select="ErrorCode"/>
<xsl:text> means </xsl:text>
<xsl:apply-templates select="$codes-top">
<xsl:with-param name="curr-errorcode" select="ErrorCode"/>
</xsl:apply-templates>
</xsl:template>


<xsl:template match="Codes">
<xsl:param name="curr-errorcode"/>
<xsl:variable name="tempError" select="normalize-space($curr-errorcode)"/>
<xsl:variable name="tempMsg" select="key('code-lookup', $tempError)/Description"/>
<xsl:variable name="fieldName" select="key('code-lookup', $tempError)/Field"/>

<xsl:value-of select="$tempMsg"/>

<xsl:text> : Field Name : </xsl:text><xsl:value-of select="$fieldName"/>
</xsl:template>

Currently I am getting outputs like:

Error: Error1 means Invalid action indicator : Field Name : actionIndicator
Error: Error2 means Invalid user : Field Name : userName

But I need to get output as following.

................................................
Error: Error1 means Invalid action indicator
Error: Error2 means Invalid user

Fields:
actionIndicator
userName
................................................

I have already spend several hours trying to figure out groupings but with lookup values I am not getting much luck. Can anyone help me with this please!!!.

Regards,
K

Postnext
(Deleted User) Subject: Grouping on lookup values.
Author: (Deleted User)
Date: 20 Sep 2007 06:58 AM
Hi Khalid,
if you want to have the Fields to be written at the end, you shouldn't invoke the apply-templates in the SystemError template; you should instead create a template for ErrorGroup and fill it with a apply-template, then a for-each on SystemError with the call to Codes inside it.

Hope this helps,
Alberto

Posttop
Khalid AnsariSubject: Grouping on lookup values.
Author: Khalid Ansari
Date: 20 Sep 2007 11:16 AM
Thanks Alberto,
I ended up putting two different templates and then I used mode in the apply template to call each template one after another.

Thanks,
Khalid

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.