Introspect internal Doc Type schema to extract constraint

Hi all wM gurus - I am hoping someone has had this requirement and found an elegant solution.

Let’s say I call pub.schema:validate and my “zipCode” field is invalid because it doesn’t comply to the internal Address document I’m validating against.

Say my value is “1234567” and my schema constraint is that zipCode has to be 5 bytes long. So pub.schema:validate will exit with “isValid=false” and contain an “errors” Doc list with fields “pathName”, “errorCode” and “errorMessage”.

The errorMessage will say something like “field is too long”. What I need to extract is the actual constraint value of that zipCode field (i.e., 5 bytes). I’m guessing that internally, this may be an attribute of the zipCode XML tag and so it must exist. I just don’t know how to get that constraint value.

Any ideas on how this can be done via a Java API or other built-in service? One solution I came up with involves using a property file that contains these constraints but I want to avoid using an external file.

  • Rajesh

Rajesh,

You have to add the constraint in the XML Schema itself,so that when you are validation xml document against the schema,it will throw the error like “field is too long” etc…

HTH,
RMG.

Hi RMG - Yes, I think we’re talking about the same thing. What you’re referring to as “XML Schema” is what I’m calling “Internal Address document”. So in the Address document, there is a string called zipCode with constraint of “totalDigits=5”.

Then when I get a document with zipCode of “1234567” for example, the constraint is broken. What I need to extract is the constraint value (i.e., “totalDigits=5”).

Ok, found a service that will give this:

wm.server.ns:getNode in WmRoot package.

great,but be aware of using WmRoot services which actually developed for internal webMethods server use.