xsl-list
[Top] [All Lists]

RE: XSL: Error Detection?

2003-03-11 08:20:47
From: Bhandari, Ashish [mailto:Ashish(_dot_)Bhandari(_at_)gs(_dot_)com]
Sent: Tuesday, March 11, 2003 7:23 AM
Subject: [xsl] XSL: Error Detection?

Hi,

Now: I have these constraints:
      - The Stylesheet is already done and it is an overkill 
for each node
translation to check for the node in the "ERROR" subtree.
      - Since I am translating only a subset , I will not be 
interested in
the "ERROR" subtree if the nodes that I am translating are 
not specified in
the subtree.
      - NOTE: It IS possible to change the way,means and mode 
the input
XML reports the error.

Goal:
       Is it possible , with minimum invasion, to make the styleesheet
capable of such error detection ?. 

I'm not sure I understand your question fully, but I'll assume that your
stylesheets each look for a single node in the input tree to transform.  If
so, then you could check for the presence of an error condition at the
beginning of the transformation:

<xsl:template match="/">
  <xsl:choose>
    <!-- you may need to use "ERROR//some-node" instead -->
    <xsl:when test="ERROR/some-node">
      <!-- report error condition -->
    </xsl:when>
    <xsl:otherwise>
      <!-- perform transformation as usual -->
    </xsl:otherwise>
  <xsl:choose>
</xsl:template>

If an error in the XML formatting occurs, does it move the problem node to
the ERROR node-set so that it doesn't appear in its normal place in the
tree?  If so, you could have two matching templates--one which outputs
whatever your error message is, and one to transform the normal input:

<!-- Error handling -->
<xsl:template match="/document/ERROR/some-node">
  <!-- etc. -->
</xsl:template>

<!-- Normal operation -->
<xsl:template match="/document/some-node">
  <!-- etc. -->
</xsl:template>

Even if your node-set still appears in the rest of the input tree, you could
add the error-handling template to the beginning of your current stylesheet,
which would allow you to output error messages and meet your "minimum
invasion" criterion.

hth,
b.

| brian martinez                              
brian(_dot_)martinez(_at_)trip(_dot_)com |
| lead gui programmer                                    303.708.7248 |
| trip network, inc.                                 fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| http://www.cheaptickets.com/                   http://www.trip.com/ |

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



<Prev in Thread] Current Thread [Next in Thread>