Wednesday 15 August 2012

xml - Can a variable from xsl version 1 be used into a xsl version 2? -



xml - Can a variable from xsl version 1 be used into a xsl version 2? -

the first file variable created has next format:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:date="java.util.date" xmlns:vector="java.util.vector" xmlns:xalan="http://xml.apache.org/xalan" extension-element-prefixes="date vector xalan"> <xsl:output method="text" indent="yes" encoding="iso-8859-1"/> <xsl:variable name="myvariabletemp"> <a> <xsl:element name="elementa"> <xsl:attribute name="a1">1</xsl:attribute> <xsl:attribute name="a2">2</xsl:attribute> </xsl:element> <!-- more elements --> </a> </xsl:variable> <xsl:variable name="myvariable" select="xalan:nodeset($myvariabletemp)"/>

the sec file want utilize looks this:

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:date="java.util.date" xmlns:vector="java.util.vector" xmlns:math="java.lang.math" xmlns:int="java.lang.integer" xmlns:long="java.lang.long" xmlns:double="java.lang.double" xmlns:saxon="http://saxon.sf.net/" xmlns:xalan="http://xml.apache.org/xalan" xmlns:exsl="http://exslt.org/common" xmlns:bigint="java:java.math.biginteger" extension-element-prefixes="date vector math int long double saxon xalan exsl bigint"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>

is there way utilize variable in sec file without changing version of either of them?

i have tried using <xsl:include href="os_settings.xsl"/>.

it depends on xslt processor want use. if utilize xalan of course of study recognize , back upwards xalan namespace , phone call xalan:nodeset. if utilize saxon won't recognize xalan namespace , throw error on phone call xalan:nodeset. not question of version set version attribute, rather question of xslt processor want use. if main stylesheet uses xslt/xpath 2.0 features of course of study won't far xalan running stylesheet, different topic.

in similar question on exsl:node-set back upwards in saxon 9 think suggested implement extension function e.g.

<xsl:function name="xalan:nodeset()"/> <xsl:param name="seq"/> <xsl:sequence select="$seq"/> </xsl:function>

that might workaround saxon, including or improve importing module should define dummy function, should possible import , utilize other module.

xml xslt xslt-1.0 xslt-2.0

No comments:

Post a Comment