playMaker

Author Topic: DataMaker/XPath  (Read 14623 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 298
    • View Profile
DataMaker/XPath
« on: March 03, 2015, 09:54:21 AM »
I'm trying to use Data Maker and learn XPath syntax at the same time.  I've never worked with it before.  I was hoping someone could help me with the xPath syntax.

The XML files I'm processing have a slightly different format than those used in DataMakers examples.  My XML output looks like this:

Code: [Select]
<layer name="H_2_Poppy" xPos="260.5"  yPos="-342"  layerwidth="91" layerheight="66" fileName="H_2_Poppy.png"/>
How would I query this and store the xPos, yPos and fileName?

Many thanks in advance!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: DataMaker/XPath
« Reply #1 on: March 04, 2015, 01:04:50 AM »
Hi,

 I'll reply with a working sample, please bump me towards the end of the week . Hyper busy right now :)

 Bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 298
    • View Profile
Re: DataMaker/XPath
« Reply #2 on: March 05, 2015, 08:28:06 AM »
Bump! 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: DataMaker/XPath
« Reply #3 on: March 06, 2015, 01:31:46 AM »
Hi,

 Thanks for the bump :)

Please find attached the sample ( published with U4.3.4)

I store the xml in a text file and use a proxy to reference that asset.

then I use the action only :)  XmlSelectSingleNode

The actual xpath query is:

//layer[@name='H_2_Poppy']

but since you likely want the name to be dynamic and hosted in an fsm variable, you change it to:

//layer[@name='_0_']

and add a variable associated to the xpath query. Check the "XmlSelectSingleNode" in the demo to see how the xpath si then parsed using the variable values

this XmlSelectSingleNode action can in one go also retrieve properties of the found node ( only if found obviously), and the last part of the action gets the various informations you need, notice the automatic conversion of variable tapes, since in xml everything is a string, you can still however store values inside any fsm variable, the conversion will be done automatically or warn if impossible.

The "Store Reference" property of the action is simply a way to save in memory the found node so that later in the game, ANYWHERE in your scenes on any fsm, you can query again that node simply by reference the value of "Store Reference".

 hopefully, that will explains the process clearly, search the web for tutorials on xml xpath and experiment online, you'll find numerous xpath testers to validate your queries quickly. However, the context is slightly different in XmlMaker so it's usefull also to check out the various examples to really get a feeling of the most used types of xpath queries.

Bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 298
    • View Profile
Re: DataMaker/XPath
« Reply #4 on: March 06, 2015, 09:04:33 AM »
Thank you for your help!  Unfortunately my console won't stop spamming the following errors when I import your package:

Unable to find style '' in skin 'DarkSkin' Layout
UnityEngine.GUIStyle:op_Implicit(String)
DataMakerActionEditorUtils:EditFsmXmlSourceField(Fsm, FsmXmlSource) (at Assets/PlayMaker DataMaker/_internal_/Editor/DataMakerActionEditorUtils.cs:122)
XmlSelectSingleNodeEditor:OnGUI() (at Assets/PlayMaker DataMaker/Xml/Actions/Editor/XmlSelectSingleNodeEditor.cs:23)
HutongGames.PlayMakerEditor.ActionEditor:OnGUI(FsmStateAction)
HutongGames.PlayMakerEditor.StateInspector:DoActionGUI(FsmStateAction)
HutongGames.PlayMakerEditor.StateInspector:DoActionsListGUI(FsmState)
HutongGames.PlayMakerEditor.StateInspector:DoActionsPanel()
HutongGames.PlayMakerEditor.StateInspector:OnGUI()
HutongGames.PlayMakerEditor.InspectorPanel:OnGUI(Rect)
HutongGames.PlayMakerEditor.FsmEditor:OnGUI()
FsmEditorWindow:DoGUI() (at Assets/PlayMaker/Editor/FsmEditorWindow.cs:94)
HutongGames.PlayMakerEditor.BaseEditorWindow:OnGUI()
UnityEditor.DockArea:OnGUI()

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: DataMaker/XPath
« Reply #5 on: March 08, 2015, 11:28:20 PM »
Hi,

 Ignore this, It's a warning, and it doesnt' affect your game. I know it's a pain. The new DataMaker Package will be out soon.

 Bye,

 Jean

 

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 298
    • View Profile
Re: DataMaker/XPath
« Reply #6 on: March 09, 2015, 08:38:30 AM »
Unfortunately that means there's something else wrong.  After importing your example package into a project and looking at the FSM in the editor, I see this error:


To test this I've imported the package into a new project and two existing projects, but all show the same error.  Other than the 999+ warning messages I mentioned above, there is one error:

Quote
Query: Select Single Node and get properties: State 1: XmlSelectSingleNode: Failed to convert Array: xPathVariables From: CustomClass To: FsmString
UnityEngine.Debug:LogError(Object)
HutongGames.PlayMaker.ActionReport:LogError(PlayMakerFSM, FsmState, FsmStateAction, Int32, String, String)
HutongGames.PlayMaker.ActionData:LogError(String)
HutongGames.PlayMaker.ActionData:TryConvertParameter(FsmStateAction, FieldInfo, Int32)
HutongGames.PlayMaker.ActionData:TryRecoverAction(Type, FsmStateAction, Int32)
HutongGames.PlayMaker.ActionData:CreateAction(FsmState, Int32)
HutongGames.PlayMaker.ActionData:LoadActions(FsmState)
HutongGames.PlayMaker.FsmState:LoadActions()
HutongGames.PlayMaker.Fsm:InitData()
HutongGames.PlayMakerEditor.FsmErrorChecker:DoCheckFsmForErrors(Fsm)
HutongGames.PlayMakerEditor.FsmErrorChecker:DoCheckForErrors()
HutongGames.PlayMakerEditor.FsmErrorChecker:Update()
HutongGames.PlayMakerEditor.FsmEditor:Update()
FsmEditorWindow:Update() (at Assets/PlayMaker/Editor/FsmEditorWindow.cs:319)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

Any help is appreciated!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: DataMaker/XPath
« Reply #7 on: March 09, 2015, 11:11:03 PM »
Hi,

 ok, let me quickly wrap up the xmlData with a new package, I'll publish it today.

 Bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 298
    • View Profile
Re: DataMaker/XPath
« Reply #8 on: March 11, 2015, 09:52:07 AM »
*bump*

Sorry for the bother Jean.  I'm almost done!  Just need a bit more help to finish this.  Let me know if you get time to publish/fix the example package at least.

Thank you as always!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: DataMaker/XPath
« Reply #9 on: March 11, 2015, 10:43:41 AM »
Hi,

 yeah, I got carried away updating arrayMaker and uGui, sorry :) this is coming next.

 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: DataMaker/XPath
« Reply #10 on: March 12, 2015, 01:58:26 AM »
Hi,

 some examples got corrupted, so I only sharing this here for now, until I can go over ll samples and clean them up.

"Books" and "Queries" ( your sample) was verified.

Please download here

BACKUP as always, this is an edgy time between u4, u5, playmaker updates and addons, so make sure you are safe when you import updated packages.

Let me know how it goes.


 Bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 298
    • View Profile
Re: DataMaker/XPath
« Reply #11 on: March 12, 2015, 08:54:00 AM »
Hi Jean,

Thanks for the quick answers.  I'm looking at the new examples now.  I created a clean project, and only imported: 1-Playmaker, 2-ArrayMaker, 3-DataMaker and 4-DataMakerSamples, in that order.

After importing the DataMakerSamples, Unity reports one error:
Quote
Assets/Photon Unity Networking/Editor/PhotonNetwork/AccountService.cs(181,45): error CS0433: The imported type `Newtonsoft.Json.JsonConvert' is defined multiple times

I then loaded the scene "SelectSingleNodeAndGetProperties" under the XML/Examples/Queries folder.  Once loaded Unity reports this error:
Quote
Query: Select Single Node and get properties: State 1: XmlSelectSingleNode: Failed to convert Array: xPathVariables From: CustomClass To: FsmString
UnityEngine.Debug:LogError(Object)
HutongGames.PlayMaker.ActionReport:LogError(PlayMakerFSM, FsmState, FsmStateAction, Int32, String, String)
HutongGames.PlayMaker.ActionData:LogError(String)
HutongGames.PlayMaker.ActionData:TryConvertParameter(FsmStateAction, FieldInfo, Int32)
HutongGames.PlayMaker.ActionData:TryRecoverAction(Type, FsmStateAction, Int32)
HutongGames.PlayMaker.ActionData:CreateAction(FsmState, Int32)
HutongGames.PlayMaker.ActionData:LoadActions(FsmState)
HutongGames.PlayMaker.FsmState:LoadActions()
HutongGames.PlayMaker.Fsm:InitData()
HutongGames.PlayMakerEditor.FsmErrorChecker:DoCheckFsmForErrors(Fsm)
HutongGames.PlayMakerEditor.FsmErrorChecker:DoCheckForErrors()
HutongGames.PlayMakerEditor.FsmErrorChecker:Update()
HutongGames.PlayMakerEditor.FsmEditor:Update()
FsmEditorWindow:Update() (at Assets/PlayMaker/Editor/FsmEditorWindow.cs:319)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

I'm still not able to learn anything from the sample either.  When I look at the FSM in the example scene, the Xml Select Single Node action has the same error I reported above with the "Error Editing Action.  Array index is out of range."

The action seems self explanatory, but even if I copy your xPath syntax it does not work for me in my scene.  Just for the record: all my packages are up to date and I'm on Unity 4.6.2.

Thank you as always.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: DataMaker/XPath
« Reply #12 on: March 12, 2015, 10:58:46 AM »
Hi,

 Yeah, the Newtonsoft dll can't be imported twice, simply delete either my version of this dll or Photon's one, it doesn't matter which.

 then it should all compile properly after that ( you may have to close and reopen the project for Unity to be happy.

We'll sort it out!!!  :P

 Bye,

 Jean

lkmad

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
Re: DataMaker/XPath
« Reply #13 on: April 24, 2015, 01:00:38 AM »
Having similar issues, adding DataMakerXml to my Unity project that already has ArrayMaker. Using Unity 5.

Is DatamakerXml updated to Unity 5 like ArrayMaker was? Could I just install DatamakerXml and skip ArrayMaker?

It messed up my project with various compiling errors (it created duplicates for some files, and then it said something about assigning different GUID to two files) and the Playmaker window has since disappeared.  :/

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15210
  • Official Playmaker Support
    • View Profile
Re: DataMaker/XPath
« Reply #14 on: April 28, 2015, 01:11:28 AM »
Hi,

 Yeah, simply delete the ArrayMaker folder and the dataMaker folder and reimport clean.

The duplicated guid is a know issue when you go from unity 4 to unity 5, after that it will be ok.


Bye,

 Jean