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
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext 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

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
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.