xsl-list
[Top] [All Lists]

Re: [xsl] would like to simplify my XSLT

2007-01-29 07:36:36
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

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