Jump to content

Xpath Is Incorrect.


MrFish

Recommended Posts

I'm trying to learn xslt and apparently have a problem with my XPath. I'm new to this and I really hate it, but a necessary evil, correct? Well here is my very first xslt test and it says I have a problem with the XPath in the xslt file.

Error loading stylesheet: Parsing an XPath expression failed.
Here is my xml file-
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="xsltest1.xsl"?><browser>	<firefox>		<speed>fast</speed>		<rating>*****</rating>	</firefox>	<chrome>		<speed>fast</speed>		<rating>****</rating>	</chrome>	<ie>		<speed>moderate</speed>		<rating>**</rating>	</ie></browser>

Here is my xslt file-

<?xml version="1.0" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	<xsl:template match="browser/*/">		<xsl:apply-templates select="speed"/>	</xsl:template>	<xsl:template match="speed">		SpEEeeeEd. 	</xsl:template></xsl:stylesheet>

I know it's the wildcard character it doesn't like, but I think that should be ok because it follows the format that Tizag uses (Not using w3schools on this one, I go back and forth.)http://www.tizag.com/xmlTutorial/xslapplytemplates.phpSo why won't this work? I don't need it for practical purposes, this is just my first test.

Link to comment
Share on other sites

I think it may be due to the leading slash "/" after the wildcard. Try this:

<xsl:template match="browser/*">

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...