当我运行当前的 XHTML 页面时,出现以下错误:
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>
这是我的 XHTML 代码:
<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>
这是我的Javascript代码:
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();}
这是我的 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
我很想添加我的 XQuery 代码,但这个框不允许我添加。 我有我的代码的照片,但您不让我在不复制和粘贴代码的情况下发布照片。 当此框不允许我向您提供代码时,我如何向您提供代码?
您需要用分号终止声明,即 try
declare default element namespace "http://www.TedTheSpeedlearner.com";
declare option exist:serialize "method=text media-type=text/plain";