xsl-list
[Top] [All Lists]

[xsl] order on lookup values.

2007-09-19 09:36:06
I have a lookup xml which contains both description and filed names for each 
error code in my source xml.

<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 XSL to combine errorcodes, descriptions and 
fieldnames.





  <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



Field Names:

actionIndicator

userName

I tried different approaches but none worked for me.  Can someone help me 
please.
Thanks,
Khalid Ansari



      
____________________________________________________________________________________
Catch up on fall's hot new shows on Yahoo! TV. Watch previews, get listings, 
and more!
http://tv.yahoo.com/collections/3658

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] order on lookup values., Khalid Ansari <=