>我有低于XMl,我需要将root="替换为动态GUID值。
我该如何实现这一目标? 可以位于 XML 文档中的任何位置。我不知道如何正确发布。堆栈流不断发出警告,以进一步解释以下问题,然后是代码。所以我正在尝试这样做。
<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。 但不知何故它不起作用。
<?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">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<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>
<!-- This could be a parm also. -->
<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>