[TUTORIAL] XML Patch Guide
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
you can either use the method mentioned here before for adressing the nth node (here the 2nd):
//pointlist/point[2]/@r
or you find an unique attribute in them, which does not have to be the same as the one you want to modify (the 2nd from your example here, too ^^):
//pointlist/point[@z='-3094.52']/@r
alternatively try if the game now supporsts the msel extension, although i doubt it does..
//pointlist/point[2]/@r
or you find an unique attribute in them, which does not have to be the same as the one you want to modify (the 2nd from your example here, too ^^):
//pointlist/point[@z='-3094.52']/@r
alternatively try if the game now supporsts the msel extension, although i doubt it does..
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Thank you, UniTrader!
In such cases other ways for replace are too bulky IMHO. This is just example which not very often used, perhaps.
msel selector is not supported here as you said:
In such cases other ways for replace are too bulky IMHO. This is just example which not very often used, perhaps.
msel selector is not supported here as you said:
Code: Select all
<replace msel="//point/@r">500</replace>
[=ERROR=] Missing 'sel' attribute in 'replace' node in patch file 'extensions\simplehack\libraries\targetpoints.xml'. Skipping node.
Probably a dumb question, but if I started with this:
and wrote this:
would it output this?
or this?
edit: forgot a <bar></bar>
Code: Select all
<root>
<bar>
<foo a="1"/>
<foo a="2"/>
</bar>
</root>
Code: Select all
<diff>
<replace sel="//bar">
<bar>
</bar>
</replace>
</diff>
Code: Select all
<root>
<bar>
</bar>
</root>
Code: Select all
<root>
<bar>
<foo a="1"/>
<foo a="2"/>
</bar>
</root>
Need help.
File /md/NPC_Staff.xml
I need this
to be like this:
Tried, does not work:
Changed quotes from ' to " and vice versa, etc etc etc
Nothing works. Please help.
File /md/NPC_Staff.xml
Code: Select all
<cue name="SectionHandler" instantiate="true">
..
<actions>
..
<do_elseif value="event.param == 'cStaff_move'">
...
<dismiss_control_entity actor="$actor" object="$actor.container" />
</do_elseif>
Code: Select all
<dismiss_control_entity actor="$actor" object="$actor.container" />
Code: Select all
<do_if value="$actor.iscontrolentity">
<dismiss_control_entity actor="$actor" object="$actor.container" />
</do_if>
Code: Select all
<replace sel="//dismiss_control_entity[@actor='$actor']" >
<replace sel="*/dismiss_control_entity[@actor='$actor']" >
<replace sel="//dismiss_control_entity" >
<replace sel="*/dismiss_control_entity" >
<replace sel='//cue[@name="SectionHandler"]/actions/do_elseif[@value="event.param == 'cStaff_move'"]/dismiss_control_entity' >
<replace sel='//cue[@name="SectionHandler"]/actions/do_elseif[@value="event.param == /'cStaff_move/'"]/dismiss_control_entity' >
Nothing works. Please help.
Hey Litauen,
only way I found to reliably do that is to do a <remove ... /> and <add ... />
only way I found to reliably do that is to do a <remove ... /> and <add ... />
Code: Select all
<remove sel="//dismiss_control_entity[@object='$actor.container']"/>
<add sel="[your xpath]">
<do_if value="$actor.iscontrolentity">
<dismiss_control_entity actor="$actor" object="$actor.container" />
</do_if>
</add>
Thank you. This seems to work:
' covers single quotes inside string.
Code: Select all
<remove sel="//dismiss_control_entity[@object='$actor.container']"/>
<add sel='//cue[@name="SectionHandler"]/actions/do_elseif[@value="event.param == 'cStaff_move'"]' >
<do_if value="$actor.iscontrolentity">
<dismiss_control_entity actor="$actor" object="$actor.container" />
</do_if>
</add>
its now linked in the Stickied Topic [Index] X Rebirth Tools, Tutorials and Resources because too many Stickies clutter up the top of the Forum - less is more here
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
<add sel="/aiscript[not(interrupts)]"><interrupts/></add>
should do the trick - will result in an entry to the debuglog if that node already exists, but but that should be fine right?
(already used a case where this is useful for compatibility as example ^^)
should do the trick - will result in an entry to the debuglog if that node already exists, but but that should be fine right?
(already used a case where this is useful for compatibility as example ^^)
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
i just had such a case where i didnt want to crawl through the files and find apporiate xpaths for each, this worked fine - i just needed one line of it per Entry to be replaced:lhotski wrote:Thank you, UniTrader!
In such cases other ways for replace are too bulky IMHO. This is just example which not very often used, perhaps.
msel selector is not supported here as you said:Code: Select all
<replace msel="//point/@r">500</replace> [=ERROR=] Missing 'sel' attribute in 'replace' node in patch file 'extensions\simplehack\libraries\targetpoints.xml'. Skipping node.
<replace sel="(//@*[. = "player.copilot"])[1]">md.$Copilot</replace>
or more general:
sel="(//msel_path)[1]"
resolves to the first ocurrence of the msel path - if you delete or change nodes in such a way that the Path doesnt apply anymore after that you can have an msel-equivalent by C&Ping the Line for each ocurrense -> just write proper Comments if you do that so others understand the intention. (if the Path doesnt change count the Number in square brackets up )
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
-
- Posts: 197
- Joined: Sat, 17. Mar 12, 17:40
There's a list of valid pos arguments (is that the right term?) in the OP. Don't know how complete it is, though.kelmenwong wrote:is there a doc/ref to list what are the possible options/values for "pos" attribute?
If I remember correctly, that's default.kelmenwong wrote:like i want to insert before the end of the node, or as last child.
Yes, end of selected node is default
Other options if //foo was selected
<before/>
<foo>
<prepend/>
.....
<default/>
</foo>
<after/>
Other options if //foo was selected
<before/>
<foo>
<prepend/>
.....
<default/>
</foo>
<after/>
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
I thought that I might share something that I came up with yesterday to document and debug patch statements
My Format Thousands mod does a shed load of individual line patching and it was getting very difficult to work out which line I was having trouble with especially running it on 3.61 and 4.00 beta 2 (where a load of line patches are meant to not match)
What I needed was some suitable comments. I Googled for comments in XPath 2 and that is possible to do but they don't appear when you get
Cannot match path ..... . Skipping node. errors
I came up with the idea of adding a ['this is a comment'] condition to the select part of each line immediately after the name of the script
['this is a comment'] happens to evaluate to true, so it has no effect on the result of the XPath expression
to
so I now get an error of
Cannot match path '/mdscript[@name='Notifications']['FormatThousands library already v2']/cues/library[@name='FormatThousands' and @version < 2]' in patch file 'extensions\format_thousands\md\notifications.xml'. Skipping node.
That tells me what patch file Notifications to look at and what the patch does so that I can then make a judgement on whether its an error or working as intended. Putting the comment up the front means that you don't have to scroll to the right to see it.
I have added in messages like ['Money formatting - v3.61 and older'] and even ['$AMOUNT$ formatting 302 - all'] so that I can zero in quickly on the right line
Its much easier to see the wood from the trees now
jth
My Format Thousands mod does a shed load of individual line patching and it was getting very difficult to work out which line I was having trouble with especially running it on 3.61 and 4.00 beta 2 (where a load of line patches are meant to not match)
What I needed was some suitable comments. I Googled for comments in XPath 2 and that is possible to do but they don't appear when you get
Cannot match path ..... . Skipping node. errors
I came up with the idea of adding a ['this is a comment'] condition to the select part of each line immediately after the name of the script
['this is a comment'] happens to evaluate to true, so it has no effect on the result of the XPath expression
Code: Select all
<remove sel="/mdscript[@name='Notifications']/cues/library[@name='FormatThousands' and @version < 2]"/>
Code: Select all
<remove sel="/mdscript[@name='Notifications']['FormatThousands library already v2']/cues/library[@name='FormatThousands' and @version < 2]"/>
Cannot match path '/mdscript[@name='Notifications']['FormatThousands library already v2']/cues/library[@name='FormatThousands' and @version < 2]' in patch file 'extensions\format_thousands\md\notifications.xml'. Skipping node.
That tells me what patch file Notifications to look at and what the patch does so that I can then make a judgement on whether its an error or working as intended. Putting the comment up the front means that you don't have to scroll to the right to see it.
I have added in messages like ['Money formatting - v3.61 and older'] and even ['$AMOUNT$ formatting 302 - all'] so that I can zero in quickly on the right line
Its much easier to see the wood from the trees now
jth
I have a problem i can't seem to fix, keep getting cannot match path errors.
This diff does not execute:
Even though the xml im patching (GM_Defend_Station) looks like this (13 and 3031):
And this (3001):
13 and 3031 fails, while 3001 executes properly.
What am i missing? Any help appreciated!
This diff does not execute:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<diff>
<add sel="//add_npc_line[@line='13']" type="@hidechoices">false</add>
<add sel="//add_npc_line[@line='3031']" type="@hidechoices">false</add>
<add sel="//add_npc_line[@line='3001']" type="@hidechoices">false</add>
</diff>
Code: Select all
<actions>
<do_if>
...
<do_elseif value="event.param == 'c_offer_accept'">
<add_npc_line line="3031"/>
<signal_cue cue="MissionAccepted"/>
</do_elseif>
<!--Decline case-->
<do_elseif value="event.param == 'c_offer_decline'">
<do_if value="$EventOffer">
...
</do_if>
<do_else>
<add_npc_line line="13" comment="Whatever."/>
<!-- restart Accepted event listener -->
<reset_cue cue="ShowOffer"/>
</do_else>
Code: Select all
<actions>
<add_conversation_view view="facenormal"/>
<do_if value="event.name" exact="'event_conversation_started'">
<add_npc_line line="3001"/>
</do_if>
What am i missing? Any help appreciated!
I think this XPath resolves to two possible nodes (the line 13 and 1031 are at least two times in the file) - find a way to address them individually
@jth
useful idea - especially if some paths fail for version or mod compatibility stuff
@jth
useful idea - especially if some paths fail for version or mod compatibility stuff
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help