Re: [xsl] would like to simplify my XSLT

Subject: Re: [xsl] would like to simplify my XSLT
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 29 Jan 2007 15:34:40 +0100
Abel Braaksma wrote:

You are using translate(), which hints (imo) that you are using XSLT 1. Can you confirm? Or do you use XSLT 2 (this highly influences the answers you will get)?

Here's one solution. I believe it will work on both 1.0 and 2.0, but I tested only 2.0.


   <xsl:template match="* | text()">
       <xsl:apply-templates />
   </xsl:template>

   <xsl:template match="
                 person[document[
                 not(@relid =
                 ../../../documents/document/@id)]]">

       <person name="{name}" />
   </xsl:template>

It will output all persons that have at least one not-matching @relid, like this, for your input:

<person name="Chris" />

Your own code much resembles the way you may do it in imperative languages like Java, PHP, VB or C. However, using templates, you can let the processor do the math for you and you only have to draw the rules.

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

Current Thread