2013-05-21 64 views
4

我使用xslt文檔,它使用xpath版本2功能。我只有2.6 xalan的罐子具有XSLT 1.0處理器,其約束我不能改變it..please幫助我,如果有一些轉換的XPath 2.0函數1.0如何將xslt版本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> 

回答

2

我會嘗試任何工具,但這是未經測試:

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

基本上使用fn:existsfn:stringfn:boolean可以更換,當然,如果有使用的XPath/XSLT 2.0的東西一樣tokenizefor-each-group你需要更多的工作,也許具體的Xalan擴展函數。

1

這應該是不壞翻譯

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

這裏是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和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)] 

參考