xml - XSLT perform identity transform and use transformed data -


this question has answer here:

fiddling still xslt. changed approach solution using id-transformation, can't out, how use transformed items directly (if possible)

sources 2 lists, combined id-transformation. mapping-list transformed xml, items imported $items variable.

<mapping>     <sub id="1" item="a" group="a">     <sub id="2" item="b" group="a">     <sub id="3" item="d" group="b">     <sub id="4" item="e" group="b">     <sub id="5" item="f" group="c"> </mapping>  <items>     <item id="a" val="ok"/>      <item id="b" val="error"/>     <item id="c" val="ok"/>     <item id="d" val="ok"/>     <item id="e" val="ok"/>     <item id="f" val="ok"/> </items> 

using id-transformation, change sub-nodes newitem-nodes, adding information second list , adding desired attributes.

<xsl:template match="node() | @*">     <xsl:copy>         <xsl:apply-templates select="node() | @*"/>     </xsl:copy> </xsl:template>  <xsl:template match="sub">     <xsl:element name="newitem">         <xsl:apply-templates select="@*"/>         <xsl:apply-templates select="$items/item[@id = ./@item]/@group"/>     </xsl:element> </xsl:template> 

but after seems can't generated newitem-nodes. using template, selecting them type, nothing works, possible generate output, not further processing?

with xslt version=1.0 can use extension "not-set". put new generated content in variable , use

 <xsl:apply-templates select="exsl:node-set($newitem_var) /> 

to make woke have add following lines.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform"     xmlns:exsl="http://exslt.org/common"     extension-element-prefixes="exsl"     version="1.0"> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -