更新的代码:
<?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>
变量“PatName”可能会遇到“DOE JOHN”,我需要将其转换为“DOE ^ JOHN”名称中也可能有多个空格,所以我希望所有“空格”更改为插入符并保留其名称中的当前位置。
我需要对名称中的逗号执行相同的操作。
目前,输出与输入一样,因此我的测试无法正常工作。
感谢您的关注!
EDIT #2:
我已经更改了我的代码以应用身份转换(希望我的代码是正确的!)此外,我还有处理我的 XSL 样式表时的 XSL 输入和 XSL 输出。
<?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 输入here http://www.pastebin.ca/2655849
XSL 输出如下:
<?xml version="1.0" encoding="UTF-8"?>
<dataset/>
在 XSL 输入中,“患者姓名”中有“SMPTE PATTERN”,我期待“SMPTE^PATTERN”。
我希望这能有所帮助,并且希望我的身份转换器是正确的。
谢谢大家的时间