skip to Main Content

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 &quot;return&quot;, 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


  1. Chosen as BEST ANSWER

    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:

    <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 onload = "Setup()">
         <input type="button" id="Bezier_Curve_Button" onclick="Setup2()" value="Click Me!" position = "absolute" top = "100px"/>
         <svg xmlns="http://www.w3.org/2000/svg" id="My_SVG" position = "absolute" top = "200px" height="500px" width="600px">
         <path id="Bezier_Curve_1"/>
         <path id="Bezier_Curve_2"/>
         </svg>
    </body>
    

    Here is my Javascript:

        function Setup() {
        var Bezier_Curve_Identification;
        var Attribute_Name;
        var Attribute_Name_2;
        var Coordinate;
        var My_Properties;
        var Button_Identification;
        
        
        
        Attribute_Name = "d";
        Attribute_Name_2 = "style";
        My_Properties = "stroke: blue; stroke-width: 3; fill: none;";
        Coordinate = "M 375 200 A 50 50 0 0 1 475 200";
        Button_Identification = document.getElementById('Bezier_Curve_Button');
        Button_Identification.setAttribute = ("style", "top: 100px; height: 200px;");
        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;
        var Bezier_Curve_1;
        var Bezier_Curve_2;
        var Counter;
        var Coordinate_Attribute;
        var Coordinate;
        var Style_Attribute;
        var Style_Details;
        var Bezier_Curve_Identification;
        
        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;
                  Retrieved_Data = Retrieved_Data.split("/");
                  Counter = 0;
                  Bezier_Curve_1 = Retrieved_Data[Counter];
                  Counter = Counter + 1;
                  Bezier_Curve_2 = Retrieved_Data[Counter];}
                  Bezier_Curve_1 = Bezier_Curve_1.split("*");
                  Counter = 0;
                  Coordinate_Attribute = Bezier_Curve_1[Counter];
                  Counter = Counter + 1;
                  Coordinate = Bezier_Curve_1[Counter];
                  Counter = Counter + 1;
                  Style_Attribute = Bezier_Curve_1[Counter];
                  Counter = Counter + 1;
                  Style_Details = Bezier_Curve_1[Counter];
                  Bezier_Curve_Identification = document.getElementById('Bezier_Curve_1');
                  Bezier_Curve_Identification.setAttribute(Coordinate_Attribute, Coordinate);
                  Bezier_Curve_Identification.setAttribute(Style_Attribute, Style_Details);
                  Bezier_Curve_2 = Bezier_Curve_2.split("*");
                  Counter = 0;
                  Coordinate_Attribute = Bezier_Curve_2[Counter];
                  Counter = Counter + 1;
                  Coordinate = Bezier_Curve_2[Counter];
                  Counter = Counter + 1;
                  Style_Attribute = Bezier_Curve_2[Counter];
                  Counter = Counter + 1;
                  Style_Details = Bezier_Curve_2[Counter];
                  Bezier_Curve_Identification = document.getElementById('Bezier_Curve_2');
                  Bezier_Curve_Identification.setAttribute(Coordinate_Attribute, Coordinate);
                  Bezier_Curve_Identification.setAttribute(Style_Attribute, Style_Details);
                  
                  };
    
    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>375 200 </Coordinate_Start>
            <Arc_Attribute>A </Arc_Attribute>
            <Bezier_Arc>50 50 0 0 1  </Bezier_Arc>
            <Terminal_Coordinate>475 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>375 200 </Coordinate_Start>
             <Arc_Attribute>A </Arc_Attribute>
             <Bezier_Arc>50 50 0 0 0 </Bezier_Arc>
             <Terminal_Coordinate>475 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>
    

    And here is my Xquery:

        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)
    let $Seventh_Data_Name := $doc/Style_Attribute
    let $Data := concat($Data, "*", $Seventh_Data_Name, "*")
    let $Eighth_Data_Name := $doc/Style_Color
    let $Data := concat($Data, $Eighth_Data_Name)
    let $Ninth_Data_Name := $doc/Style_Width
    let $Data := concat($Data, $Ninth_Data_Name)
    let $Tenth_Data_Name := $doc/Style_Fill
    let $Data := concat($Data, $Tenth_Data_Name)
    let $doc := doc("SVG_Bezier_Curve_Data.xml")/SVG_Data_Collection/Bezier_Curve_2
    let $First_Data_Name := $doc/Main_Attribute
    let $Data2 := concat($First_Data_Name, "*")
    let $Second_Data_Name := $doc/Initial_Attribute
    let $Data2 := concat($Data2, $Second_Data_Name)
    let $Third_Data_Name := $doc/Coordinate_Start
    let $Data2 := concat($Data2, $Third_Data_Name)
    let $Fourth_Data_Name := $doc/Arc_Attribute
    let $Data2 := concat($Data2, $Fourth_Data_Name)
    let $Fifth_Data_Name := $doc/Bezier_Arc
    let $Data2 := concat($Data2, $Fifth_Data_Name)
    let $Sixth_Data_Name := $doc/Terminal_Coordinate
    let $Data2 := concat($Data2, $Sixth_Data_Name)
    let $Seventh_Data_Name := $doc/Style_Attribute
    let $Data2 := concat($Data2, "*", $Seventh_Data_Name, "*")
    let $Eighth_Data_Name := $doc/Style_Color
    let $Data2 := concat($Data2, $Eighth_Data_Name)
    let $Ninth_Data_Name := $doc/Style_Width
    let $Data2 := concat($Data2, $Ninth_Data_Name)
    let $Tenth_Data_Name := $doc/Style_Fill
    let $Data2 := concat($Data2, $Tenth_Data_Name)
    return ($Data, $Data2)
    

  2. You need to terminate declarations with a semicolon i.e. try

    declare default element namespace "http://www.TedTheSpeedlearner.com";
    declare option exist:serialize "method=text media-type=text/plain";
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search