Hello,
I am having trouble merging an XHTML and XML document into one.
The key differentiator is that I am merging the docs using parameters rather
than document() to load them, as they are already loaded in memory and I do
not have access to the physical files at this point (nor would I wish to
reload them when I already have the raw xml).
Now in order to merge them I want to use an XSL transformation.
The setup:
I start by transforming a sample xml doc with a sample xsl doc to get some
HTML...
---------------------------------------------------------------------
sample.xml
---------------------------------------------------------------------
<?xml version="1.0"?>
<data>
<FirstName>Bruce</FirstName>
<LastName>Lee</LastName>
</data>
---------------------------------------------------------------------
sample.xsl
---------------------------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:value-of select="FirstName"/>
<br/>
<input id="btnDoSomething" type="button" value="Do Something"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The result looks something like this...
<html xml...>
<body>
Bruce
<br/>
<input id="btnDoSomething" type="button" value="Do Something"/>
</body>
</html>
Everything is coolio so far.
The merge (and the problem):
Now I want to merge this resulting XHTML with a new XML file.
The new xml file I wish to use is...
---------------------------------------------------------------------
newsample.xml
---------------------------------------------------------------------
<?xml version="1.0"?>
<RenderingControl>
<ElementToBeChanged>
<Name>btnDoSomething</Name>
<RenderAs>Read-Only</RenderAs>
</ElementToBeChanged>
</RenderingControl>
So I use the following XSL file with two parameters. The first parameter I
pass in the XHTML from my first transformation, and the second parameter I
pass in the raw xml from newsample.xml...
---------------------------------------------------------------------
DocumentMerge.xsl
---------------------------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:output method="xml" indent="no"/>
<xsl:param name="param-1"/>
<xsl:param name="param-2"/>
<xsl:template match="/">
<NewPage>
<xsl:copy-of select="$param-1"/>
<xsl:copy-of select="$param-2"/>
</NewPage>
</xsl:template>
</xsl:stylesheet>
I would expect the result to be a new XML file like...
<NewPage>
<html xml...>
<body>
Bruce
<br/>
<input id="btnDoSomething" type="button" value="Do Something"/>
</body>
</html>
<RenderingControl>
<ElementToBeChanged>
<Name>btnDoSomething</Name>
<RenderAs>Read-Only</RenderAs>
</ElementToBeChanged>
</RenderingControl>
</NewPage>
Instead I get the xml repeated back to me.
I assumed it had something to do with a built-in MSXML30 nuance (because of
the little WC3 compliance stink) where they no longer implicitly cast
parameters as node-sets - now treating the parameters as one giant string so
I tried using the msxml extension function (including the msxml namespace
declaration) as such...
...
<xsl:copy-of select="msxml:node-set($app-data)"/>
<xsl:copy-of select="msxml:node-set($sec-cred)"/>
...
To no avail :(
SaberBruce
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list