xsl-list
[Top] [All Lists]

Re: [xsl] Newbie Question: Creating Error Description from Invalid Input

2006-10-13 08:35:41



It seems like you mainly want to copy stuff

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

But change request to response

<xsl:template match="request">
<response>
<xsl:apply-templates/>
</response>
</xsl:template>

zap all elements that mach some "error predicate" (no child node in
this case)

<xsl:template match="header/*[not(node()]"/>

If there are any error elements, add an errordescription

<xsl:template match="header">
<header>
<xsl:apply-templates/>
<xsl:variable name="bad" select="*[not(node()]"/>
<xsl:if test="$bad">
 <errorDescription>
  <xsl:text>Invalid Elements:</xsl:text>
  <xsl:for-each select="$bad">
    <xsl:value-of select="name()"/>
    <xsl:if test="position()!=last()">,</xsl:if>
   </xsl:for-each>
 <errorDescription>
</xsl:if>
</header>
</xsl:template>


David

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