I'am trying to combine 2 xml documents, taking some attribute values in the first one and injecting it in the other.
My first xml : Manual.xml has this form : I have something like 5 000 tasks as the following :
<task chapnbr="05"
sectnbr="11"
subjnbr="04"
pgblknbr="08"
breaknbr="001"
confnbr=""
confgtxt=""
func="200"
seq="001"
confltr=""
chg="u"
key="t051104200001"
revdate="20070615">
<effect effrg="ALL">
The second xml I handle : Dictionary.xml :
<dictionary engine="CFM56" version="3" manual="ESM">
<task oldkey="T050000870001"
newkey="TKESM050000870001"
chapnbr="05"
sectnbr="00"
subjnbr="00"
func="870"
seq="001">
<title>GENERAL - INTRODUCTION</title>
</task>
<task oldkey="T051100200001"
newkey="TKESM051100200001"
chapnbr="05"
sectnbr="11"
subjnbr="00"
func="200"
seq="001">
<title>LIFE LIMITS OF ENGINE ROTATING PARTS</title>
</task>
<task oldkey="T051101200001"
newkey="TKESM051101200001"
chapnbr="05"
sectnbr="11"
subjnbr="01"
func="200"
seq="001">
<title>FAN ROTOR - LIFE LIMITS</title>
</task>
<task oldkey="T051102200001"
newkey="TKESM051102200001"
chapnbr="05"
sectnbr="11"
subjnbr="02"
func="200"
seq="001">
<title>HIGH PRESSURE COMPRESSOR ROTOR - LIFE LIMITS</title>
I need to take the value of the attribute "seq" in the Dictionary and replace it in the Manual if the attribute "oldkey" in the Dictionary is equal to the attribute "key" in the Manual.
To do that i have wrote this XSLT :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:output
encoding="UTF-8"
method="xml"
indent="yes"
omit-xml-declaration="yes"
cdata-section-elements="comments"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@seq[parent::task]">
<xsl:variable name="oldkey" select="upper-case(../@key)"/>
<xsl:attribute name="seq">
<xsl:value-of select="document('./Dictionary.xml')/dictionary/task[@oldkey=$oldkey]/@seq"/>
</xsl:attribute>
</xsl:template>
But the result i obtain is that all the values of "seq" are changed and replaced by a blank in the Manual. Here an example of output :
<task chapnbr="72"
sectnbr="00"
subjnbr="00"
pgblknbr="01"
breaknbr="011"
confnbr=""
confgtxt=""
func="810"
seq=""
confltr=""
chg="u"
key="t720000810011"
revdate="19981015">
I guess my problem comes from the way i use the document() function but I have tried many things and nothing changes. The result is allaways the same, I don't manage to obtain another value except a blank in the attribute "seq" of my output file Manual.
No comments:
Post a Comment