I have a generated XML file that looks like the following:
<PublishFACSR xmlns="http://www.ibm.com/maximo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDateTime="2015-07-14T09:23:24-06:00" transLanguage="EN" baseLanguage="EN" messageID="1436887397443667260" maximoVersion="7 5 20140411-2000 V7511--1" event="1">
<FACSRSet>
<SR action="Replace">
<ACCUMULATEDHOLDTIME>0.0</ACCUMULATEDHOLDTIME>
<ACTLABCOST>0.0</ACTLABCOST>
<ACTLABHRS>0.0</ACTLABHRS>
<TICKETID>SR-35102</TICKETID>
<TICKETUID>39822</TICKETUID>
<URGENCY changed="1">3</URGENCY>
<VENDOR />
<VIRTUALENV>0</VIRTUALENV>
</SR>
</FACSRSet>
</PublishFACSR>
I need to replace:
PublishFACSR with SyncFACSR
SR action="Replace" with SR action="AddChange"
I tried using the following XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- This template copies everything that doesn't have a more specific rule -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- This template copies and renames PublishMXASSET to SyncMXASSSET -->
<xsl:template match="PublishMXASSET">
<SyncMXASSSET>
<xsl:apply-templates/>
</SyncMXASSSET>
</xsl:template>
</xsl:stylesheet>
it generated the following output:
<SyncFACSR creationDateTime="2015-07-14T12:34:19-06:00" transLanguage="EN" baseLanguage="EN" messageID="1436898852543140608" maximoVersion="7 5 20140411-2000 V7511--1" event="1">
<FACSRSet xmlns="http://www.ibm.com/maximo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SR action="Replace">
<ACCUMULATEDHOLDTIME>0.0</ACCUMULATEDHOLDTIME>
<ACTLABCOST>0.0</ACTLABCOST>
<ACTLABHRS>0.0</ACTLABHRS>
<TICKETID>SR-35102</TICKETID>
<TICKETUID>39822</TICKETUID>
<URGENCY>3</URGENCY>
<VENDOR />
<VIRTUALENV>0</VIRTUALENV>
</SR>
</FACSRSet>
</SyncFACSR>
The biggest problem is that the namespaces have been moved down to the FACSRSet. I assume this is something with the order in which the XML is being generated and the XSL applied.
The output should look like the following:
<SyncFACSR xmlns="http://www.ibm.com/maximo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDateTime="2015-07-14T12:34:19-06:00" transLanguage="EN" baseLanguage="EN" messageID="1436898852543140608" maximoVersion="7 5 20140411-2000 V7511--1" event="1">
<FACSRSet>
<SR action="Replace">
<ACCUMULATEDHOLDTIME>0.0</ACCUMULATEDHOLDTIME>
<ACTLABCOST>0.0</ACTLABCOST>
<ACTLABHRS>0.0</ACTLABHRS>
<TICKETID>SR-35102</TICKETID>
<TICKETUID>39822</TICKETUID>
<URGENCY>3</URGENCY>
<VENDOR />
<VIRTUALENV>0</VIRTUALENV>
</SR>
</FACSRSet>
</SyncFACSR>
Any ideas on how to resolve.
Oh, and fix the action="AddChange"
thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…