0
我在xslt中遇到了问题。我的问题是,我在xml中获得了一行,应该将其替换为xsl。我想替换由informatica本身生成的informatica文件。切换顶级元素
起初,这里是我的xsl:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="xml"
indent="yes"
omit-xml-declaration="no"
media-type="string"
encoding="ISO-8859-1"
doctype-system="deftable.dtd"
/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//AUTOEDIT2[@NAME='%%PARAM']">
<xsl:choose>
<xsl:when test="../JOB[@JOBNAME]='FILE_STUFF'">
<AUTOEDIT2 NAME="%%PARAM" VALUE="*"/>
</xsl:when>
<xsl:when test="../JOB[@JOBNAME]='DATA_STUFF'">
<AUTOEDIT2 NAME="%%PARAM" VALUE="*"/>
</xsl:when>
<xsl:when test="../JOB[@JOBNAME]='TANSFER_STUFF'">
<AUTOEDIT2 NAME="%%PARAM" VALUE="*"/>
</xsl:when>
<xsl:otherwise>
<AUTOEDIT2 NAME="%%PARAM" VALUE="20150910"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
现在,这是我的XML,在更换时应做到:
<SOMETREE>
<JOB JOBNAME="FILE_STUFF">
<AUTOEDIT2 NAME="%%PARAM" VALUE="not so important, should be overwritten"/>
</JOB>
<JOB JOBNAME="DATA_STUFF">
<AUTOEDIT2 NAME="%%PARAM" VALUE="not so important, should be overwritten"/>
</JOB>
<JOB JOBNAME="TANSFER_STUFF">
<AUTOEDIT2 NAME="%%PARAM" VALUE="not so important, should be overwritten"/>
</JOB>
<JOB JOBNAME="OTHER_STUFF">
<AUTOEDIT2 NAME="%%PARAM" VALUE="not so important, should be overwritten"/>
</JOB>
</SOMETREE>
所以我要覆盖值 “VALUE” AUTOEDIT2字段,与JOBNAME相关。
非常感谢您的时间。
问候 比约恩