DarkW1nter
DarkW1nter

Reputation: 2841

how to loop through an element containing encoded xml in xslt

I have a node in a schema which contains encoded xml.

Once parsed in my xslt, I need to loop through it and do what I have to do mapping-wise.

Looking for pointers on how this should be done, just now I have

 <xsl:value-of select="*xpath to the encoded xml/text()*" disable-output-escaping="yes"/> 

But I'm not sure if I should put this into a variable, could I even loop through it if it was in a variable?

I'm thinking of mapping the encoded xml element to a schema of it's own and dealing with it there. Any thoughts?

Upvotes: 2

Views: 353

Answers (1)

zurebe-pieter
zurebe-pieter

Reputation: 3266

I recently tried to answer a similar question here: mapping a string containing xml in BizTalk

It involves two mappings with an intermediate format in between:

Example Input message:

<root>
  <someNode>blabla</someNode>
  <any>&lt;root2&gt;&lt;myValue&gt;escapedXml&lt;/myValue&gt;&lt;/root2&gt;</any>
</root>

You can map this message to an intermediate format, where you unescape the escaped XML in your input message into its own schema.
You can unescape the string using System.Web.HttpUtility.HtmlDecode() for example.

Example intermediate format:

<root>
  <someNode>blabla</someNode>
  <any>
    <root2>
      <myValue>escapedXml</myValue>
    </root2>
  </any>
</root>

Having a separate schema supporting all possibilities of the escaped XML, will allow you to validate the incoming message easily and will give you a better visual representation.

In a second mapping, where you use the intermediate format as input, you can then map towards your final destination schema, using either the BizTalk mapper or, like real BizTalkers do, plain XSLT ;-)

Upvotes: 2

Related Questions