You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Anthony Zawacki <zw...@us.ibm.com> on 2001/05/22 16:02:31 UTC

"Simple Transformation" doesn't transform properly

Hello,

I think I'm doing something fairly simple, yet I'm having some
difficulting.  I'm trying to transform a xerces dom tree and the output is
not as I expected.

The overall goal is to add a single attribute to a top level node.

The source XML (DOM->XalanDocument):
<msg sid="1" ns="true" mgw_src="???" ms="MGW"><se a="800" uui="" d="???"
iid="" as="???" /></msg>

The XSLT (DOM->Precompiled->StylesheetRoot*):
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version
="1.0">
    <xsl:template match="rm_xml">
        <msg><xsl:attribute name="md">DM</xsl:attribute><xsl:copy-of select
="@*" /><xsl:copy-of select="./*" /></msg>
    </xsl:template>
</xsl:stylesheet>

The resulting XML(XalanDocument->DOM):
<msg sid="1" md="DM">1true???MGW</msg>

The frustrating thing about this is that when I use SimpleTransform with
the source XML and XSLT, it works as I expect...

Expected output:
<msg md="DM" sid="1" ns="true" mgw_src="???" ms="MGW"><se a="800" d="???"
iid="" as="???"/></msg>

Something that may be helpful is that if I rearrange the XSLT a little and
put the copy-of select="@*" section before the xsl:attribute section, the
transformation process returns a warning that you can't add an attribute
after adding a child to an element.

I'm also a little confused as to how sid="1" gets into the message, but the
"1" is also repeated with the msg body next to the true from ns.

Does anyone have any ideas on what I may be doing wrong?  I though I would
be fairly safe in the xsl:copy-of select="@*", but that looks like where
the problem is coming from...

Thanks,
Anthony