Hi guys,
This below is my code:

<script language="javascript" type="text/javascript">
			function bc () {
			 var bc = document.getElementsByTagName("BusinessCard");		 
			 
			 for (var i=0; i < bc.length; i++) {
				var create_card = document.createElement("div");
				create_card.setAttribute("class" , "BusinessCard" );
				create_card.setAttribute("className" , "BusinessCard" );
				document.getElementsByTagName("body")[0].appendChild(create_card);
			}
		}

    </script>
</head>

<body onload="bc()" >
<BusinessCard>
	<Name>Somebody Somewhere</Name>
	<phone numba="primary" type="mobile">1234-4321</phone>
	<phone type="work">555-3000</phone>
	<phone type="fax">777-1234</phone>
	<email>me@you.com</email>
</BusinessCard>        
</body>

It works just fine in *.html but in .xslt it gives me:

SAXParseException: Expected an element name (DOMIII.xsl, line 15, column 22)

What my code says is:
Some xml business cards and DOM reference of these objects returns me an array and by using loop I'm creating a div for each BC giving it a class attr and creating it as a real DOM node.
Any suggestions why am I facing this error in XSLT?
Thanks

the error doesn't match your example code. in line 15 is an empty line. if you don't provide a complete example. how could anybody be able to help?

for now, i would say your xsl or xml is not valid xml.

Here it is:

<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="businesscard.xml" -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Untitled Document</title>
    <script language="javascript" type="text/javascript">
			function roky() {
			 var bc = document.getElementsByTagName("BusinessCard");		 
			 
			 for (var i=0; i < bc.length; i++) {
				var create_card = document.createElement("div");
				create_card.setAttribute("class" , "BusinessCard" );
				create_card.setAttribute("className" , "BusinessCard" );
				document.getElementsByTagName("body")[0].appendChild(create_card);
			}
		}

    </script>
</head>

<body onload="roky()" >
<BusinessCard>
	<Name>Joe Marini</Name>
	<phone numba="primary" type="mobile">(415) 555-4567</phone>
	<phone type="work">(800) 555-9876</phone>
	<phone type="fax">(510) 555-1234</phone>
	<mail>email: <email>joe@joe.com</email></mail>
</BusinessCard>        
</body>
</html>

</xsl:template>
</xsl:stylesheet>

you have to escape the '<' in line 15. Instead of:

for (var i=0; i < bc.length; i++) {

use:

for (var i=0; i &lt; bc.length; i++) {

Thank you very much dknochen, I would never think of that I mess with the special characters :)
Wish you all the best

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.