Subject: [xsl] Copy element referenced to From: "Taco Fleur \(@DataBroker\)" <taco@xxxxxxxxxxxxx> Date: Tue, 26 Jul 2005 11:02:58 +1000 |
Hi all, I have a template in one of my stylesheets that is supposed to do the following; - Copy everything except the @name and @identity attribute from the element it references to - Copy everything where the following matches ="$fieldCollection/field[ current()/@identity = @identity ]/ - Copy and overwrite any values above with the the values from the XML file passed into the stylesheet The problem I am having is that it does not copy the referenced fields over, i.e. step one does not work. <xsl:template match="field"> <xsl:copy> <xsl:copy-of select="@*" /> <!-- Calculate the field number --> <xsl:attribute name="number"> <xsl:value-of select="count( preceding-sibling::field ) + 1" /> </xsl:attribute> <!-- If the field element contains a reference attribute we need to first copy the element it is refering to --> <xsl:if test="$fieldCollection/field[ current()/@identity = @identity ]/@reference"> <xsl:copy-of select="$fieldCollection/field[ current()/@identity = @referece ]/@*" /> <xsl:element name="$fieldCollection/field[ current()/@identity = @referece ]/*"> <xsl:copy-of select="$fieldCollection/field[ current()/@identity = @referece ]/*" /> </xsl:element> </xsl:if> <!-- Copy all elements and attributes from the field collection --> <xsl:copy-of select="$fieldCollection/field[ current()/@identity = @identity ]/@*" /> <xsl:element name="$fieldCollection/field[ current()/@identity = @identity ]/*"> <xsl:copy-of select="$fieldCollection/field[ current()/@identity = @identity ]/*" /> </xsl:element> <!-- Also copy and override elements from the field collection with the elements passed in --> <xsl:element name="current()/*"> <xsl:copy-of select="current()/*" /> </xsl:element> </xsl:copy> </xsl:template> The XML for $fieldCollection <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <root> <field name="positiveInteger" identity="37B4604A-D9DD-713A-DB3E7C9EC4CFF509" valid="\d" minimum="1" maximum="2,147,483,647" /> <field name="companyClassId" identity="37A73A27-D9DD-713A-D8764F75D3C67A41" reference="37B4604A-D9DD-713A-DB3E7C9EC4CFF509"> <option value="1">Limited by share</option> <option value="2">Unlimited with a share capital</option> <option value="3">Limited by guarantee</option> <option value="4">No liability</option> </field> </root> The XML passed to the stylesheet: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <root> <form name="detail"> <segment value="01"> <step value="a"> <field identity="37A2CF5C-D9DD-713A-D39F89D196AA638F" required="true" display="Company type" /> </step> </segment> </form> </root> PS. Sorry I had to reply to an original post to get this message to the list, my MS Outlook 2003 will NOT sent as plain text no matter how many times I told it to.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Isolate spezial text term, Jon Gorman | Thread | [xsl] Keys working on nodeset?, Ragulf Pickaxe |
Re: [xsl] Isolate spezial text term, Jon Gorman | Date | RE: [xsl] Copy element referenced t, Taco Fleur \(@DataBr |
Month |