xsl-list
[Top] [All Lists]

Re: [xsl] Writing array elements based on a an evaluation of one of the child elements

2006-05-24 05:52:42
neil cave wrote:

In the example I want the result XML to write the first 2 occurences
of ACCOUNT-LIST because the have values in teh ACCOUNT-NO element.
Whereas occurence 3 of ACCOUNT-LIST has no ACCOUNT-NO and I don't
want that occurence in teh result doc.

  It is more clear.  But I don't see the problem:

    ~> cat nick-young.xsl
    <xsl:transform
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        version="2.0">

      <xsl:output method="text"/>

      <xsl:template match="/">
        <xsl:apply-templates select="*/ACCOUNT-LIST" mode="one"/>
        <xsl:text> - -&#10;</xsl:text>
        <xsl:apply-templates select="*/ACCOUNT-LIST" mode="two"/>
      </xsl:template>

      <xsl:template match="ACCOUNT-LIST" mode="one">
        <xsl:if test="ACCOUNT-NO/text()">
          <xsl:value-of select="ACCOUNT-NO"/>
          <xsl:text>&#10;</xsl:text>
        </xsl:if>
      </xsl:template>

      <xsl:template match="ACCOUNT-LIST" mode="two">
        <xsl:if test="string(ACCOUNT-NO)">
          <xsl:value-of select="ACCOUNT-NO"/>
          <xsl:text>&#10;</xsl:text>
        </xsl:if>
      </xsl:template>

    </xsl:transform>

    ~> cat nick-young.xml
    <?xml version="1.0" encoding="UTF-8"?>

    <Get_AccountNumber_List>
      <CLIENT_CODE6>BABICK 001</CLIENT_CODE6>
      <ACCOUNT-LIST>
        <ACCOUNT-NO>0000000054840004</ACCOUNT-NO>
        <SBU-CODE>2</SBU-CODE>
        <RISK_TYPE>CUR</RISK_TYPE>
      </ACCOUNT-LIST>
      <ACCOUNT-LIST>
        <ACCOUNT-NO>0000000710207909</ACCOUNT-NO>
        <SBU-CODE>2</SBU-CODE>
        <RISK_TYPE>CMS</RISK_TYPE>
      </ACCOUNT-LIST>
      <ACCOUNT-LIST>
        <ACCOUNT-NO></ACCOUNT-NO>
        <SBU-CODE></SBU-CODE>
        <RISK_TYPE></RISK_TYPE>
      </ACCOUNT-LIST>
    </Get_AccountNumber_List>

    ~> saxon nick-young.xml nick-young.xsl
    0000000054840004
    0000000710207909
     - -
    0000000054840004
    0000000710207909

  Mmh, I'm wondering if you don't simply want xsl:copy-of?

  Regards,

--drkm



























        

        
                
___________________________________________________________________________ 
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son 
interface révolutionnaire.
http://fr.mail.yahoo.com

--~------------------------------------------------------------------
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>