When I run my current XHTML page, I get the following error:
Retrieved_Data <?xml version="1.0" ?><exception><path>/db/apps/HTML_Student/SVG_Bezier_Curve.xq</path><message>exerr:ERROR org.exist.xquery.XPathException: err:XPST0003 expecting "return", found ';' [at line 4, column 79]</message></exception>
Here is my XHTML code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SVG_Bezier_Curve</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Bezier_Curve.css"/>
<script language="javascript" src="http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Bezier_Curve_2.js">
</script>
</head>
<body>
<input type="text" id="My_Text" value="I was here."/>
<input type="button" onclick="Setup2()"/>
<input type="button" onclick="Setup()"/>
<p id="My_Paragraph"/>
<svg xmlns="http://www.w3.org/2000/svg" id="My_SVG" height="500" width="500">
<path id="Bezier_Curve_1"/>
<path id="Bezier_Curve_2" d="M 300, 200 A 50, 50 0,0,1 400,200" stroke="red" stroke-width="3" fill="none">
</path>
</svg>
</body>
</html>
Here is my Javascript code:
function Setup() {
var Bezier_Curve_Identification;
var Attribute_Name;
var Attribute_Name_2;
var Coordinate;
var My_Properties;
document.getElementById("My_Text").value = "My Setup.";
Attribute_Name = "d";
Attribute_Name_2 = "style";
My_Properties = "stroke: blue; stroke-width: 3; fill: none;";
Coordinate = "M 300 200 A 20 20 0 0 0 400 200";
Bezier_Curve_Identification = document.getElementById('Bezier_Curve_1');
Bezier_Curve_Identification.setAttribute(Attribute_Name, Coordinate);
Bezier_Curve_Identification.setAttribute(Attribute_Name_2, My_Properties);
}
function Setup2() {
var SVG_Data;
var Retrieved_Data;
SVG_Data = new XMLHttpRequest();
SVG_Data.open("GET","http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Bezier_Curve.xq", true);
SVG_Data.onreadystatechange = function () {
if (SVG_Data.readyState == 4) {
Retrieved_Data = SVG_Data.responseText;
document.getElementById("My_Text").value = "Retrieved_Data " + Retrieved_Data;}
};
SVG_Data.send();}
Here is my XML:
<SVG_Data_Collection xmlns="http://www.TedTheSpeedlearner.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TedTheSpeedlearner.com SVG_Bezier_Curve_Data_Schema.xsd">
<Bezier_Curve_1>
<Main_Attribute>d</Main_Attribute>
<Initial_Attribute>M</Initial_Attribute>
<Coordinate_Start>300 200</Coordinate_Start>
<Arc_Attribute>A</Arc_Attribute>
<Bezier_Arc>20 20 0 0 0</Bezier_Arc>
<Terminal_Coordinate>400 200</Terminal_Coordinate>
<Style_Attribute>style</Style_Attribute>
<Style_Color>stroke: red;</Style_Color>
<Style_Width>stroke-width: 3;</Style_Width>
<Style_Fill>fill: none;</Style_Fill>
</Bezier_Curve_1>
<Bezier_Curve_2>
<Main_Attribute>d</Main_Attribute>
<Initial_Attribute>M</Initial_Attribute>
<Coordinate_Start>300 200</Coordinate_Start>
<Arc_Attribute>A</Arc_Attribute>
<Bezier_Arc>20 20 0 0 0</Bezier_Arc>
<Terminal_Coordinate>400 200</Terminal_Coordinate>
<Style_Attribute>style</Style_Attribute>
<Style_Color>stroke: blue;</Style_Color>
<Style_Width>stroke-width: 3;</Style_Width>
<Style_Fill>fill: none;</Style_Fill>
</Bezier_Curve_2>
</SVG_Data_Collection>
xquery version "3.0";
declare default element namespace "http://www.TedTheSpeedlearner.com"
declare option exist:serialize "method=text media-type=text/plain"
let $header-addition := response:set-header("Access-Control-Allow-Origin","*")
let $doc := doc("SVG_Bezier_Curve_Data.xml")/SVG_Data_Collection/Bezier_Curve_1
let $First_Data_Name := $doc/Main_Attribute
let $Data := concat($First_Data_Name, "*")
let $Second_Data_Name := $doc/Initial_Attribute
let $Data := concat($Data, $Second_Data_Name, "-")
let $Third_Data_Name := $doc/Coordinate_Start;
let $Data := concat($Data, $Third_Data_Name, "-")
let $Fourth_Data_Name := $doc/Arc_Attribute
let $Data := concat($Data, $Fourth_Data_Name, "-")
let $Fifth_Data_Name := $doc/Bezier_Arc
let $Data := concat($Data, $Fifth_Data_Name, "-")
let $Sixth_Data_Name := $doc/Terminal_Coordinate
let $Data := concat($Data, $Sixth_Data_Name)
return $Data
I would love to add my XQuery code, but this box won’t let me. I have a photo of my code, but you won’t let me post the photo without copying and pasting the code. How can I give you the code when this box won’t let me give you the code?
2
Answers
Thanks for all your assistance. I spent several hours examining each line of my code and I tested each line using the document.getElementById command. Through this command I discovered that I referenced several incorrect documents. You will notice this in the xml document. Carefully examine the $doc variable to see the before and after. I corrected several errors and for the most part my code actually works. Here is my corrected code starting with the HTML:
Here is my Javascript:
Here is my XML:
And here is my Xquery:
You need to terminate declarations with a semicolon i.e. try