hello,
I need Help. I have a problem using the character "<"other ">" in a
javasript in a XSL file.
I want to generate a table with a javasript in a XSL file. What I try is
follow:
XML-file
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" hef="translateXml.xsl"?>
- <roman name="the roman" auther="collins" romanID="600">
- <chapter name="the Crow" chapterNumber="01" type="crimi">
- <page name="page1" pageNumber="001" numberOfLine="10">
<line number="600-01-001" />
<line number="600-01-002" />
<line number="600-01-003" />
<line number="600-01-004" />
<line number="600-01-005" />
<line number="600-01-006" />
<line number="600-01-007" />
<line number="600-01-008" />
<line number="600-01-009" />
<line number="600-01-010" />
</page>
- <page name="page2" pageNumber="002" numberOfLine="11">
<line number="600-01-001" />
<line number="600-01-002" />
<line number="600-01-003" />
<line number="600-01-004" />
<line number="600-01-005" />
<line number="600-01-006" />
<line number="600-01-007" />
<line number="600-01-008" />
<line number="600-01-009" />
<line number="600-01-010" />
<line number="600-01-011" />
</page>
</chapter>
</roman>
XSL-File:
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl=" http://www.w3.org/TR/WD-xsl
<http://www.w3.org/TR/WD-xsl> ">
<xsl:template match="/">
<html>
<head><titel><h2>Roman </h2></titel>
<script language="JavaScript1.2">
var parentArray=new Array();
var childArray=new Array();
var countParent=0;
var countChild=0;
var testLine=0;
var tableLimitLength=80;
var tableLengthChild=0;
var tableLengthParent=0;
function getParentElement()
{
parentArray[countParent] = getParentElement.arguments[0];
countParent++;
}
function getChildElement()
{
childArray[countChild] = getChildElement.arguments[0];
countChild++;
}
function genereTableau()
{
parentArrayLength = parentArray.length;
childArrayLength = childArray.length;
parentArrayLengthC = parentArray.length
childArrayLengthC =childArray.length
countP=0;
countC=0;
countC1=0;
countCln=0;
do
{
countCln=0;
document.writeln('<br/><table border="1"
<caption><big><i><u>'
genereTableau.arguments[0]+"</u></i></big></caption>");
document.writeln("<tr>");
document.writeln('<td valign="center"
align="middle"><big><i>'+ genereTableau.arguments[1] +"</i></big></td>");
while(parentArrayLength)
{
while(childArrayLength)
{
countC1++;
childArrayLength--;
if(childArray[countC1-1]!="§")
{
tableLengthParent
+=childArray[countC1-1].length;
countCln++;
}
if(childArray[countC1-1]=="§" || tableLength >=
tableLimitLength)
{
break;
}
}
document.writeln('<td valign="center" align="middle"
colspan="'+countCln+'">'+parentArray[countP]+"</td>");
countP++;
parentArrayLength =parentArrayLength-1;
if(!(tableLength >= tableLimitLength ||
childArray[countC1] !="§" ))
{
tableLengthParent=0;
}
if(!(tableLength < tableLimitLength ||
childArray[countC1] =="§" ))
{
parentArrayLength++;
countP=countP-1;
tableLengthParent=0;
}
if(tableLength >= tableLimitLength)
{
tableLengthParent=0;
break;
}
alert("ParentLength="+parentArrayLength);
}
if(!testLine)
{
document.writeln("</tr>");
document.writeln("<tr>");
document.writeln('<td valign="center" align="middle" >'+
"<big><i>" + genereTableau.arguments[2] +"</i></big></td>");
testLine=1;
}
countCln=0;
while(parentArrayLengthC)
{
while(childArrayLengthC)
{
countC++;
childArrayLengthC--;
if(childArray[countC-1]!="§")
{
document.writeln('<td valign="center"
align="middle">'+
childArray[countC-1]+"</td>")
tableLengthChild
+=childArray[countC1-1].length;
tempString =
(tableLengthChild/tableLimitLength).toString();
var decoupe = tempString.split(".");
}
if(childArray[countC-1]=="§"|| tableLength >=
tableLimitLength)
{
break;
}
}
parentArrayLengthC--;
if(!(tableLength < tableLimitLength ||
childArray[countC1] =="§" ))
{
parentArrayLengthC++;
tableLengthParent=0;
}
if(tableLength >= tableLimitLength)
{
testLine=0;
tableLengthChild=0;
break;
}
}
document.writeln("</tr>");
document.writeln("</table><br/>");
}while(parentArrayLengthC);
}
</script>
</head>
<body>
<xsl:for-each select="//roman/chapter/page">
<xsl:for-each select="line">
<script language="JavaScript1.2">
getChildElement('<xsl:value-of select="@name"/>');
</script>
</xsl:for-each>
<script language="JavaScript1.2">
getParentElement('<a><xsl:attribute name="href" >#<xsl:value-of
select="@name"/></xsl:attribute><xsl:value-of select="@name"/></a>');
getChildElement("§");
</script>
</xsl:for-each>
<script language="JavaScript1.2">
genereTableau("Table of pages and their
lines","pageName","lineNumber");
</script>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
by trying to translate the Xml file with the xsl file i always get followed
error message:
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.
----------------------------------------------------------------------------
----
Whitespace is not allowed at this location. Error processing resource '
file://H:\ST05568\essais\SchemaXML-XSL\functionTest\translateXml.xsl'
<file://H:\ST05568\essais\SchemaXML-XSL\functionTest\translateXml.xsl'> .
Line 88, Position 23
if(!(tableLength < tableLimitLength || childArray[countC1] =="§" ))
----------------------^
as Browser I use internet Explorer 5.5
the result i want may look like follow:
PageName Page1
LineNumber 600-01-001 600-01-002 600-01-003 600-01-004
600-01-005 600-01-006 600-01-007
PageName Page1
Page2
LineNumber 600-01-008 600-01-009 600-01-010 600-01-001
600-01-002 600-01-003 600-01-004
PageName
Page2
LineNumber 600-01-005 600-01-006 600-01-007 600-01-008 600-01-009
600-01-010
somebody could help me?
I'm waiting for some ansewrs.
collins
This e-mail is intended only for the above addressee. It may contain
privileged information. If you are not the addressee you must not copy,
distribute, disclose or use any of the information in it. If you have
received it in error please delete it and immediately notify the sender.
Security Notice: all e-mail, sent to or from this address, may be
accessed by someone other than the recipient, for system management and
security reasons. This access is controlled under Regulation of
Investigatory Powers Act 2000, Lawful Business Practises.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list