[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="@*[key('x',.,$e)]"/> <xsl:template match="node()[key('x',.,$e)]"/> </xsl:stylesheet> $ saxon8 -sall base.xml subtract.xsl \!indent=yes <?xml version="1.0" encoding="UTF-8"?> <grocery-list> <item>milk</item> <item>cheese</item> <item>coffee</item> <item>asparagus</item> </grocery-list>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|