Groups | Blog | Home
all groups > dotnet xml > april 2004 >

dotnet xml : Strange xsltransform behaviour


s_vakareskov NO[at]SPAM hotmail.com
4/19/2004 11:29:11 AM
Hi there,
I really someone can help me. This is a real head scratcher...

I have an XSLT stylesheet that transforms perfectly when I embed the
link to it in an XML document. But if I try to use the same
stylesheet with the same XML document (with no embedded link to a
styelsheet) I get nothing in the transform.

Stylesheet, XML and vb.net code below. Any Help is much appreciated.

Thanks in advance.
-Sam

Stylesheet.
********************************************************************
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:myns="http://www.w3.org/1999/xhtml">
<xsl:output method="html"></xsl:output>
<xsl:template match="/">
<p>
<xsl:text>Stuff is: </xsl:text>
<table border="1">
<tr>
<td>

<xsl:value-of select="span/myns:html/myns:*"></xsl:value-of>
</td>
</tr>
</table>
</p>
</xsl:template>
</xsl:stylesheet>

XML
***************************************************************************
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test1.xslt" ?>
<span>

<html xmlns="http://www.w3.org/1999/xhtml">


<body >


<table >
<tr>
<td align="left" colspan="6" valign="top"></td>
</tr>

<tr>
<td align="right" colspan="6" valign="top">
<table border="0" cellspacing="0" align="right" cellpadding="0">
<tr>
<td height="19" valign="middle"></td>
<td height="19" bgcolor="#D7D7D7" class="bodytext"
valign="top">blach!</td>
<td height="19" bgcolor="#D7D7D7" class="bodytext"
valign="top">bleem</td>
</tr>
<tr>
<td align="left" colspan="5" valign="top"></td>
</tr>
</table></td>
</tr>
</table>

</body>
</html>
</span>

VB.NET source code:
********************************************************************************
dim myDoc as new XMLdocument
myDoc.load("thing.xml")

Dim myXSLT As New XslTransform
myXSLT.Load("test1.xslt")

'Dim writer As XmlTextWriter = New XmlTextWriter("data.html",
Nothing)

Dim fs As FileStream = New FileStream("out.html",
FileMode.Create)

myXSLT.Transform(myDoc, Nothing, fs, Nothing)

Oleg Tkachenko [MVP]
4/20/2004 1:51:07 PM
[quoted text, click to view]

So this instruction outputs string value of the body element, which is
empty (no text nodes in your XML). What would you expect it to be?
Oh, chances are you want to copy out body content, right?
Then use

<xsl:copy-of select="span/myns:html/myns:*/*"/>
--
Oleg Tkachenko [XML MVP, XmlInsider]
AddThis Social Bookmark Button