xpath conditional statement... need help

Started by jabbamonkey, January 11, 2019, 04:30:08 PM

Previous topic - Next topic

jabbamonkey

My graphic mod is conflicting with another mod. Without the other mod, I need to ADD graphic information for the texture.  When the other mod is installed, the ADD produces and error, so I have to use REPLACE.  I tried searching for a CONDITIONAL solution, and came up with the code below (but it doesn't work).

Please let me know what I am doing wrong...

<li class="PatchOperationConditional">
<xpath>*/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath>
<nomatch Class="PatchOperationAdd">
<success>Always</success>
<xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]</xpath>
<value>
<graphicData>
<texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>0.80</drawSize>
</graphicData>
</value>
</nomatch>
<match Class="patchOperationReplace">
<success>Always</success>
<xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath>
<value>
<texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath>
</value>

</match>
</li>

jabbamonkey

Anyone out there good with xpathing? 

I tried using the <match></match> and <nomatch></nomatch> tags to designate the conditional for the xpath... but that obviously didn't work how I intended.

Any help?

Mehni

remove the            <success>Always</success>
and you'll at least get some hints on why/where/if it's failing.

jabbamonkey

Below is part of the log...

QuoteXML error: <xpath>*/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath> doesn't correspond to any field in type PatchOperation. Context: <li class="PatchOperationConditional"><xpath>*/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath><nomatch Class="PatchOperationAdd"><xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]</xpath><value><graphicData><texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath><graphicClass>Graphic_Single</graphicClass><drawSize>0.80</drawSize></graphicData></value></nomatch><match Class="patchOperationReplace"><xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath><value><texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath></value></match></li>
Seems like it is saying that the path doesn't exist... um, but that is part of the condition. If it "matches", then show X ... it "nomatch" then do Y.  Any idea how to fix this?


Mehni

You've got a patchOperationReplace there. XML is case sensitive.

jabbamonkey

That didn't solve the issue...

QuoteXML error: <xpath>*/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath> doesn't correspond to any field in type PatchOperation. Context: <li class="PatchOperationConditional"><xpath>*/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath><nomatch Class="PatchOperationAdd"><success>Always</success><xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]</xpath><value><graphicData><texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath><graphicClass>Graphic_Single</graphicClass><drawSize>0.80</drawSize></graphicData></value></nomatch><match Class="PatchOperationReplace"><success>Always</success><xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]/graphicData/texPath</xpath><value><texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath></value></match></li>

Mehni

Post the entire xml, from <Patch> to </Patch>


Pelador

#8
It isn't because the class assertion prior to PatchOperationConditional has a lower case "c"?

Otherwise, maybe take it out of the Patch sequence as a standalone operation to see if that's the issue?

LWM


jabbamonkey

Quote from: Pelador on February 04, 2019, 07:30:54 PM
It isn't because the class assertion prior to PatchOperationConditional has a lower case "c"?

Otherwise, maybe take it out of the Patch sequence as a standalone operation to see if that's the issue?

This works fine... (but wont work when I have a mod conflict)
Quote<li Class="patchOperationAdd">
         <success>Always</success>
         <xpath>Defs/ThingDef[defName = "ExoskeletonSuit"]</xpath>
         <value>
          <graphicData>
            <texPath>Things/Item/BodyPart/ExoskeletonSuit</texPath>
            <graphicClass>Graphic_Single</graphicClass>
            <drawSize>0.80</drawSize>
          </graphicData>
         </value>
      </li>
... it's when I add the conditional that there is an issue...


LWM

Your conditional XML has <li class="PatchOperationConditional">.  Instead of <li Class="...">.

jabbamonkey

Quote from: LWM on February 06, 2019, 11:31:45 AM
Your conditional XML has <li class="PatchOperationConditional">.  Instead of <li Class="...">.

Wow. I can officially say that I hate programming. No wonder why I stick to the design side of things. That seems to be working... Let me run through the rest of the mod (and add a ton of other conditionals). Thanks.

LWM

Getting a minor case mismatch between xml and c# is not exactly the most fun part of modding; you're not alone in hitting your head against that one for a while.  At least there's that?