XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Posttop
suresh chintaSubject: Replace nodes in one xml file into another
Author: suresh chinta
Date: 31 Mar 2010 03:56 PM
Hello All:

I am trying to automate a process. I need to replace the nodes in
original xml file with those listed in a config xml file. Here is a
condensed version of files. Can some one suggest a way to replace the
nodes if the name in config xml matches the original xml file. FYI,
there are several instances of MQSourceProtocolHandler nodes
available.

Original xml file:
<MQSourceProtocolHandler name="RR_OP_ECMAP_FSH"
xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:dp="http://www.datapower.com/schemas/management">
<mAdminState>enabled</mAdminState>
<UserSummary>Route to MAP</UserSummary>
<QueueManager class="MQQM">Mainframe_QMGR_MQDA_EJB</QueueManager>
<GetQueue>KEPG2.FEPDIR.ESB.FCRLPP.XQ0000</GetQueue>
<CodePage>0</CodePage>
<GetMessageOptions>4097</GetMessageOptions>
<ParseProperties>off</ParseProperties>
<AsyncPut>off</AsyncPut>
<ConcurrentConnections>1</ConcurrentConnections>
<PollingInterval>30</PollingInterval>
<BatchSize>0</BatchSize>
<ContentTypeHeader>None</ContentTypeHeader>
<RetrieveBackoutSettings>off</RetrieveBackoutSettings>
<UseQMNameInURL>off</UseQMNameInURL>
</MQSourceProtocolHandler>

Config xml file:
<MQSourceProtocolHandler name="RR_OP_ECMAP_FSH">
<QueueManager class="MQQM">Mainframe_QMGR_MQDA_EJB</QueueManager>
<GetQueue>KEPK2.OP.ESB.RR.QL0000</GetQueue>
</MQSourceProtocolHandler>

XSL file (I need your help here!):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dp="http://www.datapower.com/schemas/management"
xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<xsl:output omit-xml-declaration="yes" method="xml" indent="yes"
version="1.0"/>
<xsl:variable name="document"
select="document('../config/configSettings.xml')/datapower-configuration"/>
<xsl:template match="node()|@*|text()">
<xsl:copy>
<xsl:apply-templates select="@*|node()|text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/MQSourceProtocolHandler">
<xsl:variable name="Config-FSH-QM-Name"
select="$document/MQSourceProtocolHandler/@name"/>
<xsl:if test="@name = $Config-FSH-QM-Name">
<xsl:apply-templates select="../MQSourceProtocolHandler"/>
<xsl:copy-of select="$document/MQSourceProtocolHandler/*"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

Expected Output:

<MQSourceProtocolHandler name="RR_OP_ECMAP_FSH"
xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:dp="http://www.datapower.com/schemas/management">
<mAdminState>enabled</mAdminState>
<UserSummary>Route to MAP</UserSummary>
<!--Text below is from the config file-->
<QueueManager class="MQQM">Mainframe_QMGR_MQDA_EJB</QueueManager>
<GetQueue>KEPK2.OP.ESB.RR.QL0000</GetQueue>
<!--Text above is from config file-->
<CodePage>0</CodePage>
<GetMessageOptions>4097</GetMessageOptions>
<ParseProperties>off</ParseProperties>
<AsyncPut>off</AsyncPut>
<ConcurrentConnections>1</ConcurrentConnections>
<PollingInterval>30</PollingInterval>
<BatchSize>0</BatchSize>
<ContentTypeHeader>None</ContentTypeHeader>
<RetrieveBackoutSettings>off</RetrieveBackoutSettings>
<UseQMNameInURL>off</UseQMNameInURL>
</MQSourceProtocolHandler>
Thanks

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.