[英]how to convert xslt version 2.0 to version 1.0
i am using xslt document which uses xpath version 2 functions. 我正在使用使用xpath版本2函数的xslt文档。 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
我只有具有xslt 1.0处理器的xalan 2.6 jar,它的约束我无法更改。.如果有任何工具将xpath 2.0函数转换为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>
Here is a mapping of the XPath 2.0 functions in question: 这是有问题的XPath 2.0函数的映射:
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. EXSLT,XSLTSL,FXSL和XPath算法可以填充大多数剩余功能。
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. Web XSLT:XSLT和JavaScript代码主要用于操纵MathML和OpenMath。
XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition) XQuery 1.0和XPath 2.0函数和运算符(第二版)
XQuery 1.0 and XPath 2.0 Formal Semantics (Second Edition) XQuery 1.0和XPath 2.0形式语义(第二版)
XQuery 1.0 and XPath 2.0 Data Model (XDM) (Second Edition) XQuery 1.0和XPath 2.0数据模型(XDM)(第二版)
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. 基本上可以替换
fn:exists
, fn:string
和fn:boolean
使用,当然,如果使用XPath / XSLT 2.0之类的东西,例如tokenize
或for-each-group
您需要做更多的工作,也许还需要Xalan特定的扩展功能。
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.