Skip to Content
0
Former Member
Feb 08, 2012 at 09:46 PM

MII XSL - Mii ignores code in transformation

190 Views

I have the following input

<Msg>
   <Hdr MsgTyp="T_Msg" Ver="2_0"/>
   <T_Msg Attr1="A" Attr2="B">
        <Node3>ZZZZ</Node3>
       <Node4>AAAA</Node4>
  </T_Msg>
</Msg>

The initial code was to take the above and give each attribute it's own element, as below

.......
<T_Msg>
    <Attr1>A</Attr1>
    <Attr2>B</Attr2>
    <Node3>ZZZZ</Node3>
    <Node4>AAAA</Node4>
</T_Msg>
....

This works as intended. However, I have to now allow for a different message (T_Msg2) to come through, and it has a child that has the same name as one of its attributes.

......
<T_Msg2 Attr1="A"  Attr2="B">
    <Attr1>ThisIsTheSecondAttr1</Attr1>
    <Node3>ZZZZ</Node3>
    <Node4>AAAA</Node4>
</T_Msg2>
........

when run through a transformation would give you the following:

.......
<T_Msg2>
    <Attr1>A</Attr1>
    <Attr2>B</Attr2>
    <Attr1>ThisIsTheSecondAttr1</Attr1>
    <Node3>ZZZZ</Node3>
    <Node4>AAAA</Node4>
</T_Msg2>
.........

I can't have the two children of T_Msg2 with the same name.

I've got an XSLT that I've done, that works perfectly on both Cooktop and another XSLT Transformer, but it will not work in MII. Mii appears to ignore the code that other transformers will run.

My code uses a xsl:call-template to make it execute the piece of code (which works anywhere but MII). The template that gets called is as follows:

......
<xsl:template name="T_Msg2">
  	<xsl:copy>
	<xsl:if test="@*">
	 <xsl:for-each select="@*">
	  <xsl:choose>
		<xsl:when test="contains(name(),'Attr1')">
		      <xsl:element name="NewAttr1">
		      	<xsl:call-template name="Attr1"/>
		     </xsl:element>
		</xsl:when>
		<xsl:otherwise>
	            <xsl:element name="{name()}">
	                <xsl:value-of select="." />	
	            </xsl:element>
		</xsl:otherwise>	
	  </xsl:choose>
	</xsl:for-each>	
	</xsl:if>
	<xsl:apply-templates />
       </xsl:copy>
  </xsl:template>

  <xsl:template name="Attr1">
		<xsl:value-of select="."/>
  </xsl:template>

Everywhere I run it (except MII), I get the desired results:

.......
<T_Msg2>
    <NewAttr1>A</NewAttr1>
    <Attr2>B</Attr2>
    <Attr1>ThisIsTheSecondAttr1</Attr1>
    <Node3>ZZZZ</Node3>
    <Node4>AAAA</Node4>
</T_Msg2>
.........

MII just returns the same thing as before - the one with 2 Attr1 elements in it.

<T_Msg2>
   <Attr1>A</Attr1>
   ......
    <Attr1>ThisIsTheSecondAttr1</Attr1>
    .....
</T_Msg2>

In addition to using the <xsl:element> above, I've tried wrapping the node name around the call-template under the When clause (in place of the element name) and I've tried wrapping it around the results returned from the Attr1 template name, but none work in Mii. Any of those options work fine in the other transformers, returning the desired results. I've also put it in a XML Loader, and evaluated the SourceUrl and can confirm that it is loading, and loading the XSL it should be. This same Url is the one I am using in the Transform property of the XSL Transformation action.

Running Mii 12.0. Any ideas?

Edited by: Steve Chatham on Feb 8, 2012 11:07 PM

Added info regarding XML Loader & results.