Reputation: 1907
i am using xslt document which uses xpath version 2 functions. I only have xalan 2.6 jar which has xslt 1.0 processor, its a constraint i cannot change it..please help me if there are any tools that convert xpath 2.0 functions to 1.0
<xsl:variable name="var1_ClinicalDocument" as="node()?" select="ns0:ClinicalDocument"/>
<DSMessage>
<DSPatient>
<xsl:for-each
select="$var1_ClinicalDocument[fn:exists(ns0:id/@root)]">
<Source>
<xsl:sequence select="fn:string(ns0:id/@root)"/>
</Source>
</xsl:for-each>
<Demographics>
<xsl:for-each select="($var1_ClinicalDocument/ns0:recordTarget/ns0:patientRole/ns0:id)[fn:exists(@extension)]">
<externalID>
<xsl:sequence select="fn:string(@extension)"/>
</externalID>
</xsl:for-each>
<xsl:for-each select="($var1_ClinicalDocument/ns0:recordTarget/ns0:patientRole/ns0:patient/ns0:name/ns0:given/node())[fn:boolean(self::text())]">
<firstName>
<xsl:sequence select="fn:string(.)"/>
</firstName>
Upvotes: 4
Views: 1055
Reputation: 24617
Here is a mapping of the XPath 2.0 functions in question:
XPath 2.0 XPath 1.0 Xalan-Java XSLT-C fn:exists() string-length(concat(., ) ) XPath 1.0 XPath 1.0 fn:string() string() XPath 1.0 XPath 1.0 fn:boolean() boolean() XPath 1.0 XPath 1.0
EXSLT, XSLTSL, FXSL, and XPath algorithms can fill in most of the remaining functionality.
XPath 2.0 FXSL XSLTSL EXSLT XPath 1.0 fn:max maximum math:max fn:max dyn:max fn:min minimum math:min fn:min dyn:min fn:sum sum math:sum sum fn:sum dyn:sum fn:avg sum div count fn:floor floor fn:ceiling ceiling fn:round round fn:abs math:abs fn:collection foldl op:concatenate append fn:doc document fn:count count fn:not not fn:true true fn:false false fn:boolean boolean fn:upper-case str:to-upper fn:lower-case str:to-lower fn:substring substring fn:string-length string-length fn:normalize-space normalize-space fn:translate translate fn:concat str:concat concat fn:substring-before substring-before fn:substring-after substring-after fn:reverse str:backward fn:insert-before str:insert-at fn:matches str:string-match fn:tokenize str:tokenize fn:resolve-uri uri:resolve-uri fn:distinct-values set:distinct op:union | op:intersect set:intersection op:except cmp:diff set:difference op:is-same-node cmp:cmp fn:position node:xpath position fn:last last fn:data node:type fn:lang lang fn:current-dateTime date:date-time fn:dateTime dt:format-date-time date:format-date fn:year-from-date dt:get-xsd-datetime-year date:day-in-year fn:month-from-dateTime dt:get-xsd-datetime-month date:month-name fn:day-from-dateTime dt:get-xsd-datetime-day date:day-name fn:hours-from-dateTime dt:get-xsd-datetime-hour date:hour-in-day fn:minutes-from-dateTime dt:get-xsd-datetime-minute date:minute-in-hour fn:seconds-from-dateTime dt:get-xsd-datetime-second date:second-in-minute fn:timezone-from-dateTime dt:get-xsd-datetime-timezone if (...) then (...) else(...) $dynamic[$var] | $default[not($var)]
References
Web XSLT: XSLT and JavaScript code intended mostly for manipulating MathML and OpenMath.
XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition)
Upvotes: 3
Reputation: 243449
This should be a not-bad translation:
<xsl:variable name="var1_ClinicalDocument" select="ns0:ClinicalDocument"/>
<DSMessage>
<DSPatient>
<xsl:for-each select="$var1_ClinicalDocument[ns0:id/@root]">
<Source>
<xsl:value-of select="ns0:id/@root"/>
</Source>
</xsl:for-each>
<Demographics>
<xsl:for-each select=
"($var1_ClinicalDocument/ns0:recordTarget
/ns0:patientRole/ns0:id)[@extension]">
<externalID>
<xsl:value-of select="concat(@extension, ' ')"/>
</externalID>
</xsl:for-each>
<xsl:for-each select=
"$var1_ClinicalDocument/ns0:recordTarget/ns0:patientRole
/ns0:patient/ns0:name/ns0:given/text()">
<firstName>
<xsl:value-of select="."/>
</firstName>
</xsl:for-each>
</Demographics>
</DSPatient>
</DSMessage>
Upvotes: 1
Reputation: 167516
I will try, but this is untested:
<xsl:variable name="var1_ClinicalDocument" select="ns0:ClinicalDocument"/>
<DSMessage>
<DSPatient>
<xsl:for-each
select="$var1_ClinicalDocument[ns0:id/@root]">
<Source>
<xsl:value-of select="ns0:id/@root"/>
</Source>
</xsl:for-each>
<Demographics>
<xsl:for-each select="($var1_ClinicalDocument/ns0:recordTarget/ns0:patientRole/ns0:id)[@extension]">
<externalID>
<xsl:value-of select="@extension"/>
</externalID>
</xsl:for-each>
<xsl:for-each select="($var1_ClinicalDocument/ns0:recordTarget/ns0:patientRole/ns0:patient/ns0:name/ns0:given/node())[self::text()]">
<firstName>
<xsl:value-of select="."/>
</firstName>
Basically the use of fn:exists
, fn:string
and fn:boolean
can be replaced, of course if there is use of XPath/XSLT 2.0 stuff like tokenize
or for-each-group
you need more work and maybe Xalan specific extension functions.
Upvotes: 2