Daniel Kutac · Jun 10, 2016

Ensemble VDOC rule - how to address document property using "Property Path"?

this is catching  me all the time, again and again...

Haven't worked with XML VDOC for some time, I can't figure out, what is the correct way of using Property path. Can someone please help me to refresh my memory.

Simple example: I have a class called Body, with Value and Topic properties. I created a XML Schema for this class and imported it into Ensemble. So i have a category called message, with Body as DocType structure and Name and Topic properties of Body complex type ($2:Value and $2:Topic are element names)

My rule looks this way:

However, the rule is ALWAYS evaluated as TRUE. but TRACE element shows null value for "value". 


I  also did a programming test using this code:


but only /Body/Value worked fine (the DOM path) and returned 30, the $2:Value returned empty string.

What am I missing?


0 844
Discussion (3)0
Log in or sign up to continue

It looks as  for $-notation one needs some DocType to be available, at least this is what %objlasterror tells.
Using [] you might get what you expect.

ENSEMBLE>write !,vDoc.GetValueAt("$1")
ENSEMBLE>write %objlasterror
0 ñ<Ens>ErrGeneral:Can't evaluate property path because DocType  is not set

Variants with []-notation:

ENSEMBLE>write !,vDoc.GetValueAt("/Body/[2]")
ENSEMBLE>write !,vDoc.GetValueAt("/[1]/[2]")

Thank you Markus for hint,

I have modified the code to read this way:

#dim vDoc as EnsLib.EDI.XML.Document=##class(EnsLib.EDI.XML.Document).ImportFromString("<Body><Topic>Temperature</Topic><Value>30</Value></Body>",.sc)
if $$$ISERR(sc) $System.Status.DisplayError(sc)


but it throws :

ERROR <Ens>ErrGeneral: Can't evaluate DOM path '/Body/$2:Value' because xsd_2:Topic in /Body/xsd_2:Value is not an element, instead this node is a 'unknown' node.


this drives me mad...

BTW: you're still using DOM way and not property path way of retrieving data.


got it. I was missing xmlns declaration.


#dim vDoc as EnsLib.EDI.XML.Document=##class(EnsLib.EDI.XML.Document).ImportFromString("<Body xmlns=""""><Topic>Temperature</Topic><Value>30</Value></Body>",.sc)

works as expected.