Forum Moderators: open

Message Too Old, No Replies

problem in using <xsl:element> in xslt

         

naga2005

2:15 am on Aug 5, 2005 (gmt 0)

10+ Year Member



Hi ,

I am learning XSLT and using the MSXML parser.

I have encountered this following error.

My XML file is : apply.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="applytemplates.xsl"?>
<simple>
<name> PETER </name>
<name> ADAM </name>
<name> GEORGE </name>
</simple>

My applytemplates.xxsl file is as follows:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/simple/name">
<xsl:element name="{.}">
My Text
</xsl:element>
</xsl:template>

</xsl:stylesheet>


And if i try to open my apply.xml file through the browser(Internet explorer 6) i get the following syntax error:


The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.

This name may not contain the ' ' character: --> <--PETER


---------------------------------------------------------
I WOULD REALLY APPRECIATE IF U HELP ME IN IDENTIFYING THE PROBLEM.

THANKS

vinyljunkie

3:46 am on Aug 5, 2005 (gmt 0)

10+ Year Member



I'm not sure why this is happening, but it is complaining about the leading and trailing spaces in your <name></name> fields. Get rid of those, and everything is fine.