Can values be set without using MAP?

Hello - I have an interesting problem - I have a table with variable XPaths and values:
/a/b/@c ← ‘XXX’
/x/y/*body ← ‘YYY’
/m/n/p/*body ← ‘ZZZ’

I need to set the variable leaf nodes on the left, to the values on the right. However, variables are stored in a bizdoc that is mapped to a generic boundNode record in the pipeline at runtime – hence I cannot use a Flow MAP step. How would I do this?

The requirement this addresses is the need to suppress certain fields containing sensitive information from display.

regards,
Sonam

To make sure I understand:

  • You’re using TN
  • You receive a document and are successfully kicking off a rule which invokes a service
  • Within the service, you have the bizdoc, get the content and have converted it to a boundNode.

You may have jumped to an erroneous conclusion about not being able to use MAP.

You can set the variables as you need to using two approaches, both of which use MAP:

  • If your boundNode is “anonymous”, meaning that Developer doesn’t know what the structure is at design time, but you know what will be there, simply force the values you want into the variables you want by defining the variables of interest by hand in the pipeline editor.

OR

  • Map the generic boundNode to the appropriate document reference of the known structure. Then in Developer in a MAP step you can open the structure to the variables of interest and set the values.

Hi Rob - Thanks: yes I am using TN. The bizdoc content is converted to boundNode as you said.

Both your options using MAP are possible - true - but they require defining record structures (or skeletal structures) for each document type at design time.

I was hoping for a way to avoid hardcoding structures and using MAP - rather I want to drive everything through a interface specifing the XPaths and values. This is because document types and subfields will change in time – for eg: a new customer uses different fields to carry sensitive data, new document types are implemented, etc. Is this possible?

Sonam,

Seems like you would need a java service that would convert the boundNode to a DOM object and then use XPath to locate the Elements you need to modify.

Probably more work than you had in mind, but possible.

Unfortunately, there isn’t a good way to convert from a Node to a DOM Document without an intermediate conversion to a string and stream.

Mark

Thanks Mark, Rob - yes, it does look like a parser is the way to go. A bit ironic to do this on webMethods IS. :frowning:

For my wishlist: a “pub.web:updateDocument” service which takes a set of XPaths and corresponding values as inputs and updates arbitrary documents. :slight_smile: Well…

Would I use a external Java SAX/DOM parser or is there a way to use WM’s internal parser and it’s spiffy sliding window techniques? :slight_smile:

That’s probably a question for a java guru with lots of experience manually parsing large XML docs.

There might be a way to do this with queryXMLNode and XQL queries instead of XPath, but you specified XPath, so I’m guessing you would want to convert to DOM and then iterate over you list of XPath queries to perform each update. This could get ugly however on large docs in which your queries were in reverse order of the document structure.

Mark

Hi Sonam,
Using the queryXMLNode and XQL queries, you could get the value of a leaf node in the pipeline, even though the XPath of that node is not FIXED. Then use the string replace to replace that value with ‘XXX’.

Regards,
Bhawesh

Thanks Mark - I’m not too fussed on XPath – XQL, WQL would all do, but there doesn’t seem to be a way to set the value.

Hi Bhawesh - Good idea regarding having the query string as a variable in queryDocument/queryXMLNode – it works, and I didn’t know that.

The problem is that I can _get_the value. However, using string replace to set the value will be problematic – for eg: if the value was something like ‘123’, and it occured in more than one place in the document – a string replace could replace the wrong part of the document.

Sonam

Hi Sonam,
Assuming that you are only working with XML docs:

Use the variable query in queryDocument/queryXMLNode and get the value of the varPositionNode in the pipeline, which is something like ‘123’ and to replace only this ‘123’ with ‘SOMEDATA’ in the whole doc:

do the string replace of “%varPositionNode%” with “SOMEDATA”.

All other ‘123’ in the document will be left as it is.

Regards,
Bhawesh

Thanks Bhawesh - but like the data, the tag may also be repeated. For eg: I may want to remove only the first “123” from here:
123123…
However, removing all instances of “123” may be a reasonable assumption. Thanks.

Hmm, another drawback could be XML parser whitespace handling - depending on the parser setting, 123 could be equivalent to:

123

http://xml.coverpages.org/rfc-wshp19990416.html

This could be handled with regexs… I do recall this one strange trading partner whose application (if i recall correctly) insisted on sending across (valid!) XML formatted like this:

<![CDATA[123]

:stuck_out_tongue:

A parser-based solution will be bulletproof against such edge cases.

Cheers,
Sonam