0

I want to display a xml in a IE browser directly using xslt 1.0 without any engine.I could get some code from the source xml,then I want to get the corresponding displayname to this code from a external xml named voc.xml.but I could not get the displayname following these instructions 1.define a document variable in the xsl

<xsl:variable name="voc" select="document('voc.xml')"/>

2.get the code following my own xpath and I can get the value of the variable 'paytypecode'='01'
3.find the corresponding code in the voc.xml

<xsl:variable name='mappedpaytypecode' select="$voc//systems/system[@root='CV07.10.003医疗费用来源类别代码表']/code[@value='01']"/> 

4.get the displayName of this corresponding code in the voc.xml

<xsl:variable name='displayName_value' select="$mappedpaytypecode/@displayname"/>  

and the voc.xml is like this

<systems>
    <system codeSystemName="CV07.10.003医疗费用来源类别代码表" root="CV07.10.003医疗费用来源类别代码表">
       <code value="01" displayname="城镇职工基本医疗保险" />
       <code value="02" displayname="城镇居民基本医疗保险" />
       <code value="03" displayname="新型农村合作医疗" />
       <code value="04" displayname="贫困救助" />
       <code value="05" displayname="商业医疗保险" />
       <code value="06" displayname="全公费" />
       <code value="07" displayname="全自费" />
       <code value="99" displayname="其他" />      
  </system> 
</systems>
edwin_uestc
  • 169
  • 2
  • 11

1 Answers1

0

I see three issues here:

  1. Your sample input document is malformed. Please inspect the closing tag of the <systems> element.
  2. XPath is case-sensitive. In your select expression for the $displayName_value variable, you have used camel-case ('@displayName'), but in your input document, you have used lower-case ('@displayname');
  3. You did not mention the range of browsers you are testing on. If FF (desktop) or IE, you are ok. Please note that Google Chrome (desktop) will not allow local-system XSLT. This is by design. I don't know if mobile browsers support client-side XSLT or not.

IE Browser

Don't forget to use the node-set() function. References:

  1. http://msdn.microsoft.com/en-us/library/hz88kef0.aspx
  2. http://dpcarlisle.blogspot.com.au/2007/05/exslt-node-set-function.html
  3. How to use node-set function in a platform-independent way?
Community
  • 1
  • 1
Sean B. Durkin
  • 12,659
  • 1
  • 36
  • 65