I'm pulling my hair out here. First, I'm new to XML, so that doesn't
help, but none of this makes any sense to me. All I'm trying to do is
take a simple source XML file and translate it with an XSLT to produce
HTML code.
The problem I have is that no matter what translation it runs through,
it ALWAYS includes data that I don't match in the XSLT!! All I want to
do is extract specific fields from the XML. Here's the XML source.
Simple...
<?xml version="1.0"?>
<rss version="0.92">
<channel>
<docs>http://backend.userland.com/rss092</docs>
<title>Comics: Calvin and Hobbes</title>
<description>Comics: Calvin and
Hobbes</description>
<managingEditor>cr*******@livejournal.com</managingEditor>
<link>http://www.ucomics.com/calvinandhobbes/</link>
<lastBuildDate>Sat, 27 Dec 2003 01:00:02
GMT</lastBuildDate>
<item>
<title>Comics: Calvin and Hobbes</title>
<link>http://images.ucomics.com/comics/ch/1992/ch921226.gif</link>
<description><img
src="http://images.ucomics.com/comics/ch/1992/ch921226.gif";
border="0"
alt="Today's Calvin and
Hobbes">
</description>
</item>
</channel>
</rss>
Now, here's the VB.NET code that I use to apply my XSLT:
Dim xslt As New XslTransform
Dim doc As New XmlDocument
Dim writer As XmlTextWriter = New
XmlTextWriter("c:\temp\transform.html", Nothing)
doc.Load("c:\temp\XMLtest.xml")
Try
xslt.Load("c:\temp\XMLtest.xslt")
xslt.Transform(doc, Nothing, writer, Nothing)
Catch ex As Xsl.XsltException
Console.WriteLine("Transform Failed")
Catch ex As Exception
Console.WriteLine(ex.Message & " " & ex.StackTrace)
End Try
MsgBox("DONE!")
Now, I have tried SO many variations of an XSLT I don't even not what
to post here. I'm taking from 3 books, and the problem is that the
exported HTML ALWAYS includes the data associated with the items that
I'm not attempting to match!
Here's my latest failure of an XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" encoding="utf-8" />
<xsl:template match="channel">
<xsl:text>
CORE CHANNEL:
</xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="channel/item">
TITLE <xsl:value-of select="title"/>
</xsl:template>
</xsl:stylesheet>
And here's the result:
CORE CHANNEL:
http://backend.userland.com/rss092Comics: Calvin and
HobbesComics: Calvin and
Hobbescr*******@livejournal.comhttp://www.ucomics.com/calvinandhobbes/Sat,
27 Dec 2003 01:00:02 GMT TITLE Comics: Calvin and Hobbes
PLEASE help me get around this pathetic problem. Obviously there's
some unnamed rule, but the 3 books that I have on the subject mention
NOTHING about this because all the examples contain data that's all
used; no throw away data.
So, how do I throw away the data I don't want when transforming with an
XSLT?
Thanks!
Moogy
------------------------------------------------------------------------
Posted via
http://www.mcse.ms
------------------------------------------------------------------------
View this thread:
http://www.mcse.ms/message217830.html