xml - Pass namespace to an included xslt -


i work 2 file transformations. main file contains import statement in second transformation file. second transform file contains several templates generic transformations. problem transformations not same data namespace. wish namespace use in second transform.

xslt1 :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:fo="http://www.w3.org/1999/xsl/format" xmlns:n="http://novamap.fr/xml/data/v1/xmlmodelbondecommande" version="1.0">    <xsl:include href="common.xslt"/>    <xsl:template match="/n:xmlmodelbondecommande">   ......   </xsl:template> </xsl:stylesheet> 

xslt2 :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:fo="http://www.w3.org/1999/xsl/format" xmlns:n="http://novamap.fr/xml/data/v1/xmlmodeletatdeslieux" version="1.0">    <xsl:include href="common.xslt"/>    <xsl:template match="/n:xmlmodeletatdeslieux">   ......   </xsl:template> </xsl:stylesheet> 

common.xslt :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:fo="http://www.w3.org/1999/xsl/format" xmlns:n="<--my problem-->" version="1.0">    <xsl:template name="doc1">     <xsl:value-of select="n:value1"/>   </xsl:template>    <xsl:template name="doc2">     <xsl:value-of select="n:value2"/>   </xsl:template>  </xsl:stylesheet> 

i want pass namespace use common.xslt xslt1 , xslt2 files

you need declare 2 namespace in included document , write code match or select elements in 2 namespace e.g. instead of <xsl:value-of select="n:value1"/> use <xsl:value-of select="n1:value1 | n2:value1"/> or better yet change stuff like

  <xsl:template name="doc1">     <xsl:value-of select="n:value1"/>   </xsl:template> 

to

  <xsl:template match="n1:value1 | n2:value1">     <xsl:value-of select="."/>   </xsl:template> 

a different approach use separate stylesheet or separate transformation step first normalizes xml input documents single namespace.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -