.net - When a template in an xsl file overlaps with a template in an included xsl file, the included xsl would not add the needed content -



.net - When a template in an xsl file overlaps with a template in an included xsl file, the included xsl would not add the needed content -

i generate various xml files , utilize them test cases programme of mine. utilize xslt generate more complex test cases basic ones avoid duplication of xml content. xsl files include other xsl files add together xml content existing test case.

i have problem: when template in xsl file overlaps template in included xsl file, included template not add together needed content.

hello.xml:

<ebc> <positionen> <position> <artikelnr>helloworldproductref</artikelnr> <herstnr>hello world! (productname)</herstnr> </position> </positionen> </ebc>

hello.xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*" /> </xsl:copy> </xsl:template> <xsl:template match="/"> <xsl:apply-templates select="document('hello.xml')/*" /> </xsl:template> </xsl:stylesheet>

1_product_in_1_cat.xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:include href="hello.xsl" /> <xsl:template match="position/*[last()]" xml:space="preserve"> <xsl:copy-of select="." /> <wwswgnr>167000</wwswgnr><wwswgname_de>mobotix ip kameras</wwswgname_de> </xsl:template> </xsl:stylesheet>

1prod_2img_1cat.xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:include href="1_product_in_1_cat.xsl" /> <xsl:template match="position/*[last()]" xml:space="preserve"> <xsl:copy-of select="." /> <bilder> <bild>12011085_grob_102.jpg</bild> <bild>12011085_090.jpg</bild> </bilder> </xsl:template> </xsl:stylesheet>

the output of hello.xsl , output of 1_product_in_1_cat.xsl right , not want alter it. output of 1prod_2img_1cat.xsl not wanted.

the actual output is

<ebc> <positionen> <position> <artikelnr>helloworldproductref</artikelnr> <herstnr>hello world! (productname)</herstnr> <bilder> <bild>12011085_grob_102.jpg</bild> <bild>12011085_090.jpg</bild> </bilder> </position> </positionen> </ebc>

the expected output is

<ebc> <positionen> <position> <artikelnr>helloworldproductref</artikelnr> <herstnr>hello world! (productname)</herstnr> <wwswgnr>167000</wwswgnr><wwswgname_de>mobotix ip kameras</wwswgname_de> <bilder> <bild>12011085_grob_102.jpg</bild> <bild>12011085_090.jpg</bild> </bilder> </position> </positionen> </ebc>

i not want 1prod_2img_1cat.xsl know much tag names , construction of hello.xml , other files. possible accomplish expected result?

please note output of hello.xsl , 1_product_in_1_cat.xsl must remain same, because used elsewhere.

by way, pass dummy empty xml file on input of xsl files, actual input defined document() function.

i think want utilize xsl:import instead of xsl:include , replace

<xsl:template match="position/*[last()]" xml:space="preserve"> <xsl:copy-of select="." /> <bilder> <bild>12011085_grob_102.jpg</bild> <bild>12011085_090.jpg</bild> </bilder> </xsl:template>

with

<xsl:template match="position/*[last()]" xml:space="preserve"> <xsl:apply-imports/> <bilder> <bild>12011085_grob_102.jpg</bild> <bild>12011085_090.jpg</bild> </bilder> </xsl:template>

.net xslt xslt-1.0

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' -