具有XSLT转换的XML值的空白属性

问题描述 投票:0回答:1

我在XMl下面,我需要用动态GUID值替换root =“”。这可以是XML文档中的任何位置。它不适用于下面的XSLT。这只是要成功发布的扩展文本。

            <ClinicalDocument xmlns="urn:hl7-org:v3">
            <templateId root="2.16.840.1.113883.10.20.22.1.2" extension="2015-08-01"/>
            <id root=""/>
            <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LN"
            displayName="Summarization of Episode Note"/>
            <title>Patient Summary Document</title>
            <languageCode code="en-US"/>
            <component>
            <structuredBody>
              <component>
                <section>
                  <templateId root="2.16.840.1.113883.10.20.22.2.6.1"/>   
                  <entry typeCode="DRIV">
                    <act classCode="ACT" moodCode="EVN">
                      <templateId root="2.16.840.1.113883.10.20.22.4.30"/>
                      <templateId root="2.16.840.1.113883.10.20.22.4.30" extension="2015-08-01"/>
                      <id nullFlavor="UNK"/>  
                      <informant>
                        <assignedEntity>
                          <id root="2.16.840.1.113883.3.86.3.1" extension="STHS"/>
                          <addr nullFlavor="UNK"/>
                          <telecom nullFlavor="UNK"/>
                          <assignedPerson>
                            <name nullFlavor="UNK"/>
                          </assignedPerson>
                          <representedOrganization>
                            <id root="" extension="STHS" displayable="true"/>
                            <name>STHS</name>
                            <telecom nullFlavor="UNK"/>
                            <addr nullFlavor="UNK"/>
                          </representedOrganization>
                        </assignedEntity>
                      </informant>
                    </act>
                  </entry>
                </section>
              </component>
            </structuredBody>
            </component>
            </ClinicalDocument>

我有XSLT以下。但它不适用于上面突出显示的标签。

            <xsl:variable name="GUID" select="'FF1122'"/>

            <xsl:template match="id/@root[.='']">
                <xsl:attribute name="root">
                    <xsl:value-of select="$GUID"/>
                </xsl:attribute>
            </xsl:template>

            <xsl:template match="@* | node()">
                <xsl:copy>
                    <xsl:apply-templates select="@* | node()"/>
                </xsl:copy>
            </xsl:template>


        </xsl:stylesheet>
xslt xslt-1.0
1个回答
0
投票
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:isc="http://extension-functions.intersystems.com"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"            
    xmlns:ns1="urn:hl7-org:v3">
  <xsl:output omit-xml-declaration="yes" indent="yes"/>

  <xsl:variable name="GUID" select="'FF1122'"/>

  <xsl:template match="ns1:id/@root[.='']">
    <xsl:attribute name="root">
      <xsl:value-of select="$GUID"/>
    </xsl:attribute>
  </xsl:template>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
© www.soinside.com 2019 - 2024. All rights reserved.