XML transform with XSLT 1 -



XML transform with XSLT 1 -

today im struggling xslt, has been long time had utilize it. have edit xml , can't utilize xslt 2.0. have utilize 1.0. xml im struugling (basic example) :

i tried making template 2 nodes, , 'call' template create new node desired values didnt work either , im missing if can point me right direction.

class="snippet-code-html lang-html prettyprint-override"><messagemap> <author> <au_id>274-80-9391</au_id> <au_lname>straight</au_lname> <au_fname>dean</au_fname> <phone>415 834-2919</phone> <address>5420 college av.</address> <city>oakland</city> <state>ca</state> <zip>94609</zip> <contract>1</contract> </author> </messagemap>

xm:

class="snippet-code-html lang-html prettyprint-override"><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output indent="yes"/> <!--identity transform.--> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="au_fname | au_lname"> <company> <xsl:value-of select="."/> </company> </xsl:template> </xsl:stylesheet>

what result:

class="snippet-code-html lang-html prettyprint-override"><messagemap> <author> <au_id>274-80-9391</au_id> <company>straight</company> <company>dean</company> <phone>415 834-2919</phone> <address>5420 college av.</address> <city>oakland</city> <state>ca</state> <zip>94609</zip> <contract>1</contract> </author> </messagemap>

what need is:

class="snippet-code-html lang-html prettyprint-override"><messagemap> <author> <au_id>274-80-9391</au_id> <company>dean straight</company> <phone>415 834-2919</phone> <address>5420 college av.</address> <city>oakland</city> <state>ca</state> <zip>94609</zip> <contract>1</contract> </author> </messagemap>

you seek matching au_fname , building company. strip au_lname.

xslt 1.0

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <!--identity transform.--> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="au_fname"> <company> <xsl:value-of select="normalize-space(concat(.,' ',../au_lname))"/> </company> </xsl:template> <xsl:template match="au_lname"/> </xsl:stylesheet>

xml xslt

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -