Recent

Author Topic: laz2_xmlcfg/TXMLConfig: What is the path syntax?  (Read 792 times)

dsiders

  • Hero Member
  • *****
  • Posts: 1084
laz2_xmlcfg/TXMLConfig: What is the path syntax?
« on: November 20, 2019, 06:12:41 pm »
Like many, I have been thoroughly confused by just TXMLConfig. For starters, where it exists (answer: in both fcl-xml and in LazUtils). I am now trying to understand the path syntax used in the LazUtils variant.

Comments in the source code imply that it is XPath. It is not. Not even close. So what is it?

My experiments with it have shown that I can't predict whether an element or an attribute is used to store the value in the xml file. Is it accurate to assume that an xml attribute is always used for the final identifier in the path expression? And, are there conditions would that assumption be wrong?

TXMLDocument looks better with each passing moment. ;)
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: laz2_xmlcfg/TXMLConfig: What is the path syntax?
« Reply #1 on: November 20, 2019, 06:43:02 pm »
I haven't looked at the details. The IDE usually uses it to load data from known paths. And the most it ever needs to do, is to check if that data exists or not.

Recent changes (in trunk / 2.1) allow for multiple entries of the same name. That is instead of <unit1>...</unit1><unit2>..., you can now have many <unit> nodes. The syntax for that afaik is '.../unit[0]/...'  (and replacing 0 as needed).

If you have your config in an object, and all properties are published, you can use the rtti version TRttiXmlConfig (you need to check if it deals with all types, that you need)

dsiders

  • Hero Member
  • *****
  • Posts: 1084
Re: laz2_xmlcfg/TXMLConfig: What is the path syntax?
« Reply #2 on: November 20, 2019, 08:28:21 pm »
Recent changes (in trunk / 2.1) allow for multiple entries of the same name. That is instead of <unit1>...</unit1><unit2>..., you can now have many <unit> nodes. The syntax for that afaik is '.../unit[0]/...'  (and replacing 0 as needed).

If you have your config in an object, and all properties are published, you can use the rtti version TRttiXmlConfig (you need to check if it deals with all types, that you need)

Thanks for the hint, I had not recognized the list/array feature yet. The RTTI-enabled version is next on my list.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

 

TinyPortal © 2005-2018