473,385 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Strange xsltransform behaviour

Sam
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)

myDoc.Save(inFileName & ".xml")
Nov 12 '05 #1
1 1182
Sam wrote:
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. <xsl:value-of select="span/myns:html/myns:*"></xsl:value-of>


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]
http://blog.tkachenko.com
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Anthony Bouch | last post by:
Can anyone tell me why I receive the following compiler warning after having recently upgraded to VS.Net 2003 and .Net 1.1? Warning CS0618: 'System.Xml.Xsl(System.Xml.XPath.IXPathNavigable,...
5
by: Kevin Westhead | last post by:
I'm using XslTransform to apply a transform to an XML document, however I get validation problems when parsing the resulting XML document due to invalid whitespace. I'm passing in an XPathNavigator...
1
by: Rodger McNab | last post by:
While parsing xpath expressions within an XSLT document the .NET XslTransform class seems to delete the first "/" after a "]" within an expression containing a "|". This problem can be demonstrated...
2
by: Graham Pengelly | last post by:
Hi I am trying to transform on System.Xml.XmlDocument into another using XslTransform without writing the object out to a file. I am guessing it should work something like this... public...
3
by: Steve | last post by:
Is there any way of specifying the startMode when using the xslTransform class? We are updating code which used msxml to the system.xml classes but can find no way to specify the startMode. We...
4
by: badbetty | last post by:
Hello and thank you for reading on (hopefully). How does one typecast the XMLREADER returned from the XSLTRANSFORM method 'transform' into XMLTEXTREADER, so it can be passed in to an...
1
by: manlio | last post by:
how can I load a XSL string (not an xsl file!!) with XslTransform ??? If I use the code: // Create a new XslTransform class and load the stylesheet XslTransform myXslTransform = new...
3
by: Eckhard Schwabe | last post by:
when switching from the old "XslTransform " to "XslCompiledTransform" I notice a difference in the handling of whitespace. I need to transform a XML file which contain tabs (\t), and which remain...
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.