[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT Subtract function?

Subject: Re: XSLT Subtract function?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 13 Apr 2007 16:28:57 +0100
Re:  XSLT Subtract function?
> What I had in mind is a function that would take four arguments:
> 1) A base document (base document) [$base]
> 2) A document containing the values to subtract from the base document (exemplar document) [$exemplar]
> 3) The XPath to the elment in the base document holding the values of interest. [$base-element]
> 4) The XPath to the element in the exemplar document holding the values of interest. [$list-element]

I'm not sure quite what you want as there can't be a _function_ like
this as you can't pass an unevaluated XPath to a function (without using
extensions like saxon:evaluate) so any pure xslt solution will have to
have (3) and (4)  appearing directly in some XSLT or Xpath expression,
in which case the resulting construct is going to look rather like what
you say you did already, although (especially in xslt 2) I'd use a key
rather than CODE = $active-codes/ROWSET/ROW/CODE

something like

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="e" select="doc('exemplar.xml')"/>

<xsl:key name="x" match="sku" use="."/>

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

<xsl:template match="@*[key('x',.,$e)]"/>
<xsl:template match="node()[key('x',.,$e)]"/>


$ saxon8 -sall base.xml subtract.xsl \!indent=yes
<?xml version="1.0" encoding="UTF-8"?>

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.