[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Issue 157 - XSLT and copy/replace semantics
Rethinking about today's discussions on this subject, and also previous discussions on the mailing list, I think there is a basic misunderstanding of what the supporters of XSLT use in copy are saying (at least some of the supporters - I don't think we have had enough discussions for me to claim to represent all the XSLT proponents). [Disclaimer: I am not proposing to get rid of copy and replace it with XSLT - I am just claiming that *in some cases* XSLT can be used to *achieve the same results* as the current copy] Let me start from Yuzo's original example because it's very simple (I modified it a little to make it even more clear and simple). Here is the var1 variable with its contents: var1: <invoice test="false"> <invoiceNumber>9876</invoiceNumber> <orderNumber>0000</orderNumber> <amount/> <billingAddress><street/></billingAddress> </invoice> Now I want to modify this variable so that its contents looks like: <invoice test="false"> <invoiceNumber>9876</invoiceNumber> <orderNumber>1234</orderNumber> <amount/> <billingAddress><street>1 Somewhere</street><state>SW</state></billingAddress> </invoice> I could use the current copy and do something like: <assign> <copy> <from><literal>1234</literal>,/from> <to>$var1/orderNumber</to> </copy> <copy> <from><literal><billingAddress><street>1 Somewhere</street><state>SW</state></billingAddress></literal></from> <to>$var1/billingAddress</to> </assign> (I am not completely sure the syntax I used above is aligned with the latest 157 discussions, but you should get the idea of what I am talking about). Instead of doing that, I could use XSLT in the following way: 1) Here is the style sheet: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="orderNumber"> <xsl:element name="orderNumber"> <xsl:value-of select="1234"/> </xsl:element> </xsl:template> <xsl:template match="billingAddress"> <xsl:element name="billingAddress"> <xsl:copy-of select= ... node corresponding to "<billingAddress><street>1 Somewhere</street><state>SW</state></billingAddress>" ... /> </xsl:element> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> 2) I take the tree contained in var1 - let's call it tree1 3) I apply the XSLT transform to tree1, yielding tree2 4) I replace the contents of var1 with tree2 5) the XSLT-based assign is done - if I look inside var1, its contents are exactly the same as if I had used the two copy operations shown before. In particular, I have achieved the same copy/replace semantics of the current BPEL copy without in any way violating the semantics of XSLT transformations (i.e. no modification of tree1) Ugo
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]