Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 8th December 2008, 15:09   #1
SilverShadow08
Junior Member
 
Join Date: May 2008
Location: Virginia
Posts: 1
Create multiple XML Nodes

Using xml.nsh plugin created by Instructor.
I am trying to create three similar Nodes at the end of Server/Services/Engine/Host. When I create just one Node everything works fine. When I generate multiples, the result is less than desirable.

My test script:
#XML Plugin Examples
Name "XMLTest"
OutFile "XMLTest.exe"
!include "XML.nsh"

# open section
section
; Example of usage

${xml::LoadFile} "C:\Contenta36Install\NSIS Scripts\test.xml" $0
${xml::GotoPath} "/config/local/host" $0
${xml::CreateNode} '<Context docBase="E:\ContentaView\" path="/servlets3"></Context>' $0
${xml::InsertEndChild} "$0" $0
${xml::CreateNode} '<Context docBase="G:\ContentaViewData\collections\NIAPS_ContentaView3.6\httpdocs\" path="/wietmsd"></Context>' $0
${xml::InsertEndChild} "$0" $0
${xml::CreateNode} '<Context docBase="G:\ContentaViewData\collections\" path="/collections"></Context>' $0
${xml::InsertEndChild} "$0" $0
${xml::SaveFile} "C:\Contenta36Install\NSIS Scripts\test.xml" $0
${xml::Unload} ; unload plugin
# end the section
SectionEnd

Test Results:
<config>
<local>
<host>
<Context docBase="E:\ContentaView\" path="/servlets3">
<Context docBase="G:\ContentaViewData\collections\NIAPS_ContentaView3.6\httpdocs\" path="/wietmsd">
<Context docBase="G:\ContentaViewData\collections\" path="/collections" />
</Context>
</Context>
</host>
</local>
</config>

Target Results for Production:
<Valve className="org.jboss.web.tomcat.tc5.jca.CachedConnectionValve" cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager" transactionManagerObjectName="jboss:service=TransactionManager" />

<Context docBase="E:\ContentaView\" path="/servlets3" />
<Context docBase="G:\ContentaViewData\collections\NIAPS_ContentaView3.6\httpdocs\" path="/wietmsd" />
<Context docBase="G:\ContentaViewData\collections\" path="/collections" />
</Host>
</Engine>
</Service>
</Server>
Notes for desired result:
The last three Context Nodes are added just before the closing Host Element without deleting any of the other Host children, i.e Valve.

Any suggestions would be gratefully appreciated.
Thank you in advance
SilverShadow08 is offline   Reply With Quote
Old 8th December 2008, 21:03   #2
HolyKami
Junior Member
 
Join Date: Dec 2008
Posts: 1
After the first {InsertEndChild} you need to move the node forward by using {InsertAfterNode}.

The XML NSIS plugin has good documentation on usage.
Below I pasted a working solution to your problem.
(Variable changes didn't matter, so don't worry about that)

# open section
section
; Example of usage

${xml::LoadFile} "C:\Documents and Settings\Administrator\Desktop\NSI XML\test.xml" $0
${xml::GotoPath} "/config/local/host" $0
${xml::CreateNode} '<Context docBase="E:\ContentaView\" path="/servlets3"></Context>' $1
${xml::InsertEndChild} "$1" $0
${xml::CreateNode} '<Context docBase="G:\ContentaViewData\collections\NIAPS_ContentaView3.6\httpdocs\" path="/wietmsd"></Context>' $2
${xml::InsertAfterNode} "$2" $1
${xml::CreateNode} '<Context docBase="G:\ContentaViewData\collections\" path="/collections"></Context>' $3
${xml::InsertAfterNode} "$3" $2
${xml::SaveFile} "C:\Documents and Settings\Administrator\Desktop\NSI XML\test.xml" $0
${xml::Unload} ; unload plugin
# end the section
SectionEnd
HolyKami is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump