Friday, December 17, 2004

Mass Copy (or not)

We have a number 'Alert' scenarios where we want to send out user alerts, and also retain the body of a message (or part thereof) for resubmission, to replay the orchestration once appropriate remedial action has been taken. I thought we could be clever, and define an envelope schema that would contain details of the alert, in human-readable form, together with an <any> element that could contain the message, for resubmission. By defining the parent of this element as the BodyXPath of the envelope, the alert message itself could be resubmitted, at which point the inner message would be stripped out and re-processed.

Alert
 |
 + - Message
 |
 + - Resubmit
      |
      + - <Any>

It was the first time I'd used the Mass Copy functoid, and was annoyed to find that it copies the children and attributes of the node selected, rather than the node itself - meaning that you lose the root node name if it isn't already in the output schema. The xsl generated is thus:

<Resubmit>
  <xsl:copy-of select="./@*" />
  <xsl:copy-of select="./*" />
</Resubmit>

(where the <resubmit> element is the parent of the <any>, and our body xpath node.)

This didn't work for us, as we needed the name of the root element copied over, so I replaced the Mass Copy functoid with a Scripting functoid, selected Inline XSLT as the script type, and used the following:

<Resubmit>
  <xsl:copy-of select="." />
</Resubmit>

I'm surprised that there isn't a property of the Mass Copy functoid that allows you to do this, as it seems relatively obvious (and easy to implement). Has anyone else had to do this?

1 comment:

Ben Runchey said...

I just ran into this one. Thanks for the little inline XSLT snippit to make it work.