UPDATED CODE:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no"/>
<!-- overwritten by application with actual values -->
<xsl:param name="calling" select="'SAMPLE_MOD'"/>
<xsl:param name="called" select="'SERVER1'"/>
<xsl:param name="date" select="'20051206'"/>
<xsl:param name="time" select="'115600.000'"/>
<xsl:param name="PatName" select="attr[@tag='00100010']"/>
<xsl:template match="/dataset">
<dataset>
<xsl:variable name="PerfProcStepDesc" select="attr[@tag='00400254']"/>
<xsl:variable name="StudyDesc" select="attr[@tag='00081030']"/>
<xsl:if test="string-length($StudyDesc)=0">
<xsl:if test="$PerfProcStepDesc">
<!-- (0008,1030) Study Description -->
<attr tag="00081030" vr="LO">
<xsl:value-of select="$PerfProcStepDesc"/>
</attr>
</xsl:if>
</xsl:if>
</dataset>
<dataset>
<xsl:variable name="caret" select="'^'"/>
<xsl:if test="contains($PatName, ' ')">
<xsl:value-of select="translate($PatName, ' ','^')"/>
</xsl:if>
</dataset>
</xsl:template>
</xsl:stylesheet>
The variable 'PatName' could come across as 'DOE JOHN' and I need it be transformed to 'DOE^JOHN' There could also be multiple spaces in the name, so I would like all 'spaces' changed to carets and to keep their current place in the name.
I need to do the same with commas that are in the name.
Currently the output coming out just as it went in, so my test is not working as it should.
thanks for looking!
EDIT #2:
I have changed my code to apply a identity transform (hopefully I have it correct!) Also I have the XSL input and XSL output for when it processed my XSL stylesheet.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no"/>
<!-- overwritten by application with actual values -->
<xsl:param name="calling" select="'SAMPLE_MOD'"/>
<xsl:param name="called" select="'SERVER1'"/>
<xsl:param name="date" select="'20051206'"/>
<xsl:param name="time" select="'115600.000'"/>
<xsl:param name="PatName" select="attr[@tag='00100010']"/>
<!-- IdentityTransform -->
<xsl:template match="/ | @* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="/dataset">
<dataset>
<xsl:variable name="PerfProcStepDesc" select="attr[@tag='00400254']"/>
<xsl:variable name="StudyDesc" select="attr[@tag='00081030']"/>
<xsl:if test="string-length($StudyDesc)=0">
<xsl:if test="$PerfProcStepDesc">
<!-- (0008,1030) Study Description -->
<attr tag="00081030" vr="LO">
<xsl:value-of select="$PerfProcStepDesc"/>
</attr>
</xsl:if>
</xsl:if>
</dataset>
<dataset>
<xsl:variable name="caret" select="'^'"/>
<xsl:if test="contains($PatName, ' ')">
<xsl:value-of select="translate($PatName, ' ','^')"/>
</xsl:if>
</dataset>
</xsl:template>
</xsl:stylesheet>
XSL Input here
XSL Output is below:
<?xml version="1.0" encoding="UTF-8"?>
<dataset/>
in the XSL input, 'Patient Name' there is 'SMPTE PATTERN' and I am expecting 'SMPTE^PATTERN'.
I hope this of some help and I hope I have the identity transformer correct.
thanks for everybodys time