Reputation: 9
I have below XMl and i need to replace root="" with Dynamic GUID value.
How do i achieve that? can be at anywhere in XML document. I do not know how to post this correctly. stackoberflow keep giving warning for more explaination of below issue then code. so i am trying to do this.
<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>
I have got XSLT from this post answer. but somehow it does not work.
<?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>
Upvotes: 0
Views: 489
Reputation: 1235
<!-- 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>
Upvotes: 1