更新的代碼: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']"/>
<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」可能遇到的「能源部JOHN」,我需要它轉化爲「能源部^約翰」也有可能存在多個空格這個名字,所以我希望所有的'空格'變成插入符號並且保留它們的名字。
我需要使用名稱中的逗號來執行相同操作。
目前輸出剛剛出現,所以我的測試不能正常工作。
感謝您的期待!
編輯#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
XSL輸出如下:
<?xml version="1.0" encoding="UTF-8"?>
<dataset/>
在XSL輸入
, '患者姓名' 有 'SMPTE模式',我希望 'SMPTE ^模式' 。
我希望這有些幫助,我希望我有身份轉換正確。
感謝每一個時間
你可能想要把開'的'標籤在那裏,以及 –
deanosaur
對不起,我忘了張貼,它是在我的樣式表 - 感謝! – Docjay
請在您的原始輸入中嘗試下面我回答中發佈的樣式表。 –