XSL转换:获取属性的值

时间:2014-05-09 23:03:03

标签: xml xslt

我正在尝试在源数据的摘录中显示下面显示的location属性的值:

<svrl:failed-assert test="cda:manufacturedMaterial/cda:code/@codeSystem = '
2.16.840.1.113883.6.88' or cda:manufacturedMaterial/cda:code/@codeSystem = 
'2.16.840.1.113883.6.59' or cda:manufacturedMaterial/cda:code/@codeSystem =
'2.16.840.1.113883.6.96'" location="/*[local-name()='ClinicalDocument' and
namespace-uri()='urn:hl7-org:v3']/*[local-name()='component' and namespace
-uri()='urn:hl7-org:v3']/*[local-name()='structuredBody' and namespace-uri(
)='urn:hl7-org:v3']/*[local-name()='component' and namespace-uri()='urn:hl7
-org:v3'][11]/*[local-name()='section' and namespace-uri()='urn:hl7-org:v3'
]/*[local-name()='entry' and namespace-uri()='urn:hl7-org:v3'][1]/*[local-n
ame()='substanceAdministration' and namespace-uri()='urn:hl7-org:v3']/*[loc
al-name()='consumable' and namespace-uri()='urn:hl7-org:v3']/*[local-name()
='manufacturedProduct' and namespace-uri()='urn:hl7-org:v3']">

        The value for manufacturedMaterial / code in a product template SHOULD  
        selected from the RxNorm (2.16.840.1.113883.6.88) code system for medicaTions,   
        and from the CDC Vaccine Code (2.16.840.1.113883.6.59) code system for 
        immunizations or MAY be selected from ValueSet 2.16.840.1.113883.1.11.20.8 
        MedicationTypeCode STATIC 200017.

</svrl:failed-assert>

我有以下转换:

<xsl:template match="schematron-output/failed-assert">
    <b><xsl:value-of select="text()/svrl:failed-assert/@test"></xsl:value-of></b>
    <b><xsl:value-of select="text()/svrl:failed-assert/@location"></xsl:value-of></b>
</xsl:template>

不显示test和location属性的值。所有显示的是:

The value for manufacturedMaterial / code in a product template SHOULD  
selected from the RxNorm (2.16.840.1.113883.6.88) code system for medicaTions,   
and from the CDC Vaccine Code (2.16.840.1.113883.6.59) code system for 
immunizations or MAY be selected from ValueSet 2.16.840.1.113883.1.11.20.8 
MedicationTypeCode STATIC 200017.

我尝试了一些像text()这样的功能来提取价值,但却没有任何工作。

1 个答案:

答案 0 :(得分:0)

考虑到您已正确声明命名空间 -

        <b><xsl:value-of select="@test"/></b>
        <b><xsl:value-of select="@location"/></b>