Hello
The error that you are getting is to do with the well-formedness of your
xslt. remember that an xslt has to also be well formed according to the xml
standard.
When the parser sees: if(!(tableLength < tableLimitLength ||
childArray[countC1] =="§" ))
the < character makes it think that you are starting a new xml tag and
because the next character is a space which is not allowed you get the
error:
Whitespace is not allowed at this location.
The answer is to replace < with its entity which is <
like this: if(!(tableLength < tableLimitLength || childArray[countC1]
=="§" ))
Cheers
Rod
-----Original Message-----
From: NTCHOUZOU Collins [mailto:collins(_dot_)ntchouzou(_at_)airbus(_dot_)com]
Sent: 05 March 2003 11:44
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: RE: [xsl] Problem with the use of JavaScript in a XSL file
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
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________
________________________________________________________________
Any opinions expressed in this email are those of the individual and not
necessarily the Company. Unless expressly stated to the contrary, this email is
not intended to give rise to a new, or affect an existing, contractual or other
legal relationship.This email and any files transmitted with it, including
replies and forwarded copies which may contain alterations) subsequently
transmitted from the Company, are confidential and solely for the use of the
intended recipient. The unauthorised use, disclosure or copying of this email,
or any other information contained or attached,is prohibited and could, in
certain circumstances, be a criminal offence.
If you have received this email in error please notify the sender as soon as
possible.
This footnote also confirms that this email message has been swept for the
presence of computer viruses.
www.focusdiy.co.uk
_________________________________________________________________
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list