[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] XML to Javascript


Subject: [xsl] XML to Javascript
From: "Philip Vallone" <philip.vallone@xxxxxxxxxxx>
Date: Fri, 26 Jan 2007 18:55:07 -0500

Hi all,

I am trying to convert some XML to Javascript for a menu-tree. Is this
possible?

I tried the following XSLT but when I run my construct in the <script> it
doesn't understand <br/>


<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ACM="www.aviationcontentmanagement.com"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xsl:output method="html"/>
	<xsl:variable name="XML1" select="/"/>
	<xsl:template match="/">
		<html>
			<head>
				<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1"/>
				<title>Project Explorer</title>
				<link rel="stylesheet" href="./tree.css"/>
				<script language="javascript"
src="scripts/tree_view.js"/>
				<script language="JavaScript"
type="text/JavaScript">

function CreateProjectExplorer()
{
	Initialise();
	
<xsl:for-each select="$XML1/manual/chapter">
						<xsl:text>d =
CreateTreeItem( rootCell, "img/project.gif", "img/project.gif", "</xsl:text>
						<xsl:value-of
select="@chaptitle"/>
						<xsl:text>", null, null
);</xsl:text>
						<br/>
						<xsl:for-each
select="title">
							<xsl:text>d2 =
CreateTreeItem(d, "img/project.gif", "img/project.gif", "</xsl:text>
							<xsl:value-of
select="document(.)//ACM:MELtitle"/>
							<xsl:text>",
"</xsl:text>
							<xsl:value-of
select="substring-before(., '.')"/>
	
<xsl:text>.html</xsl:text>
							<xsl:text>" ,
"content" );</xsl:text>
							<br/>
						</xsl:for-each>
		<br/>
</xsl:for-each>


}
</script>
			</head>
			<style type="text/css">
h2 {font-family:verdana,helvetica,sans-serif;font-size:13pt}
li {font-family:verdana,helvetica,sans-serif;font-size:11pt}
</style>
			<body>

			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>


Thanks for the help.

Phil


Current Thread
Keywords