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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.