xml - XSLT Copying text from label -
got xml
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="albaran.xsl"?> <albaran> <articulo precio="1.23" unidades="3">tornillos</articulo> <articulo precio="2.34" unidades="5">arandelas</articulo> <articulo precio="3.45" unidades="7">tuercas</articulo> <articulo precio="4.56" unidades="9">alcayatas</articulo> </albaran>
the xslt output must attribute called "total" multiplies "unidades" * "precio". output must example:
<articulo total="3.69">tornillos</articulo>
but cant manage copy text inside "articulo", "tornillos" every time... xslt:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0"> <xsl:template match="albaran"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="articulo"> <xsl:copy> <xsl:attribute name="total"> <xsl:value-of select="@precio * @unidades"/> </xsl:attribute> <xsl:value-of select="//articulo"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
<xsl:value-of select="//articulo"/>
selecting:
//
anywhere
articulo
grab first articulo
change <xsl:value-of select="."/>
value of current scope. current scope set match
portion of xsl:template
.
Comments
Post a Comment