【发布时间】:2014-04-03 23:11:59
【问题描述】:
这个问题类似于我原来的问题 [这里].1
我最初的问题是我需要每两位数插入一个连字符到一个七位数字中。现在我需要通过添加一个前导“0”将一个六位数字变成一个七位数字,然后我需要像以前一样每两个数字连字符一次。
这是我的代码,我想我已经很接近了,但还不够。
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:decimal-format name="dashes" grouping-separator='-'/>
<xsl:template match="/dataset">
<dataset>
<!-- Nullify (0040,A043) Concept Name Code Sequence -->
<attr tag="0040A043" vr="SQ"/>
<attr tag="00100021" vr="LO">HOSP</attr>
</dataset>
<dataset>
<!-- for when the leading "0" is dropped from the PID making it six digits long -->
<xsl:variable name="modPatientID" select="attr[@tag='00100020']"/>
<xsl:variable name="AddZero" select="'0'"/>
<xsl:variable name="Station" select="attr[@tag='00081010']"/>
<!-- (0008,1010) Station_Name -->
<xsl:if test="string-length($modPatientID)=6">
<xsl:if test="contains($Station,'J')">
<attr tag="00100020" vr="LO">
<xsl:value-of select="concat(
$AddZero, substring($modPatientID, 1, 2), '-',
substring($modPatientID, 3, 2), '-',
substring($modPatientID, 5, 2), '-',
substring($modPatientID, 7)
)"/>
</attr>
</xsl:if>
</xsl:if>
</dataset>
</xsl:template>
</xsl:stylesheet>
我是否应该使用上面创建的名为“AddZero”的变量名?
【问题讨论】: