cancel
Showing results for 
Search instead for 
Did you mean: 

MII XSL - Mii ignores code in transformation

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I may have stumbled upon the issue.

There was nothing wrong with the XSL - it worked perfectly in other transformers.

The transformation only started working properly when I had run a test in a transformer, and confirmed that it had run properly, and took these steps:

1. Copy the xsl from the transformer/editor.

2. Go in to MII & edit the xsl that is causing a problem.

3. CTRL-A to select all of the contents of the MII xsl, then hit DELETE to get rid of the code.

4. Hit the spacebar a few times, then SAVE the document.

5. Do another CTRL-A to select the spaces, and then PASTE your xsl code into it & save the file.

6. Now run your test.

I discovered it by making a change to an element elsewhere in the code, that should have affected BOTH of my inputs, however, it only affected ONE of them.

It appears that MII was caching some or all of the code being used in my test, even though I had been in & out of MII many times since I started testing it. Even though the XML Loader confirmed that my changes were in the code, and that ONE of the two events I ran had those changes effective in it, it appears that the xsl used for each of those transformations wasn't refreshed for BOTH until I replaced the document with nothing, and then pasted & saved the changes into it.

Is there a better way to force MII to not do essentially a dirty read on XSL transformations?