xsl-list
[Top] [All Lists]

RE: Output based on the existence of a particular piece of data in alist

2003-04-08 08:13:48
-----Original Message-----
From:     "Martin, Tripp" <tripp(_dot_)martin(_at_)commerceone(_dot_)com>
I need to make my output based on the existence of a <Status> tag
with
"Error".  So, in the case above I want to have:
<accountcheckreply>
     <success>false</success>
     <message type="error">
        <code>1</code>
        <description>Order 78960 does not exist</description>
     </message>
</accountcheckreply>
<
Whereas if there were no errors in the incoming document, 
I would have simply:
<accountcheckreply>
     <success>true</success>
</accountcheckreply>

I haven't been able to figure out what I need to use to 
make this happen.
Can anyone offer a suggestion of where to start?
===========================================================

This produces the output you asked for:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
  xmlns:AC="http://trippsnamespace.com";>
  <xsl:output method="html" indent="yes" encoding="UTF-8" />
  <xsl:strip-space elements="*" />
  <xsl:template match="/AC:validateAcctngCodeResponse">
    <xsl:apply-templates select="AcctngCodeOut" />
  </xsl:template>

  <xsl:template match="AcctngCodeOut">
    <xsl:choose>
      <xsl:when test="Status = 'Error'">
        <accountcheckreply xsl:exclude-result-prefixes="AC">
          <success>false</success>
          <message type="error">
            <code>1</code>
            <description><xsl:value-of select="StatusText" /></description>
          </message>
        </accountcheckreply>
      </xsl:when>
      <xsl:otherwise>
        <accountcheckreply xsl:exclude-result-prefixes="AC">
            <success>true</success>
        </accountcheckreply>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

<xsl:template match="UserId" />
</xsl:stylesheet>
-- 
Charles Knell
cknell(_at_)onebox(_dot_)com - email


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>
  • RE: Output based on the existence of a particular piece of data in alist, cknell <=