Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The eXist database is insisting that my Javascript code is really an Xquery code #5338

Closed
Speedlearner5 opened this issue Jun 22, 2024 · 5 comments · Fixed by eXist-db/eXide#695

Comments

@Speedlearner5
Copy link

Speedlearner5 commented Jun 22, 2024

eXist Error 1
eXist Error 2

This is my HTML code.

<html xmlns="http://www.TedTheSpeedlearner.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TedTheSpeedlearner.com SVG_Ellipse_Webpage_XML_Schema.xsd">
    <head>
        <title>SVG Ellipse</title>
        <link rel="stylesheet" type="text/css" href="http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Ellipse.css"/>
        <script language="javascript" src="http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Ellipse.js"/>
    </head>
    <body onload="Setup()">
        <svg id="Image_Box">
            <ellipse id="My_Ellipse"/>
        </svg>
    </body>
</html>

This is my css code

#Image_Box {
height: 500px;
width: 800px;}
#My_Ellipse {
fill: none;
stroke: blue;
stroke-width: 3;}

This is my Javascript code

var SVG_Data;
var Retrieved_Data;
var Attribute_List;
var Coordinate_List;
var Counter;
function Setup() {
     SVG_Data = new XMLHttpRequest();
     SVG_Data.open("GET","http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Ellipse.xq", true);
     SVG_Data.onreadystatechange = function () {
         if (SVG_Data.readyState = 4) {
            Retrieved_Data = SVG_Data.responseText;
            Retrieved_Data = Retrieved_Data.split("*");
            Attribute_List = "";
            Coordinate_List = "";
            for (Counter = 0; Counter < 8; Counter++) {
      Attribute_List = Attribute_List + Retrieved_Data[Counter] + "*";
  Counter = Counter + 1;
  Coordinate_List = Coordinate_List + Retrieved_Data[Counter] + "*";}
  Attribute_List = Attribute_List.split("*");
      Coordinate_List = Coordinate_List.split("*");
      Coordinate = "<ellipse id = 'My_Ellipse'";
    for (Counter = 0; Counter < 4; Counter++) {
         Coordinate = Coordinate + " " + Attribute_List[Counter] + " = '" + Coordinate_List[Counter] + "'";}
    Coordinate = Coordinate + ">";
     document.getElementById("Image_Box").innerHTML = Coordinate;
         }
     };
}
   SVG_Data.send();

This is my XML code

<SVG_Data_Collection xmlns="http://www.TedTheSpeedlearner.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TedTheSpeedlearner.com SVG_Ellipse_Data_Schema.xsd">
    <ellipse>
        <X_Center_Coordinate>100</X_Center_Coordinate>
        <Y_Center_Coordinate>100</Y_Center_Coordinate>
        <X_Radius_Coordinate>30</X_Radius_Coordinate>
        <Y_Radius_Coordinate>70</Y_Radius_Coordinate>
    </ellipse>
</SVG_Data_Collection>

Right now I'm running Windows 11 with all updates installed. I'm also running Java 11 and the latest version of the eXist database.
eXist Monex Error

At this moment my eXist database refuses to run as a Windows service because I turned it off and tried to turn it back on. I also cleared my cache but it had no positive effect. eXist continues to insist that my javascript code is some sort of xquery code. I don't know how to fix any of this. Can anyone assist me?

@joewiz
Copy link
Member

joewiz commented Jun 22, 2024

@Speedlearner5 The issue you describe in the title of your issue:

The eXist database is insisting that my Javascript code is really an Xquery code

... is actually an issue with eXide, the web-based XQuery development environment. Specifically, when eXide opes
a file, it tries to detect the type of file. It does a good job detecting XQuery and XML files, but I can reproduce your report - that it fails to identify Javascript files and falls back on XQuery.

I've prepared a PR to fix the problem in eXide: eXist-db/eXide#695. Once that PR is merged, I'll prepare a new release of eXide, which you can download and install to fix the problem on your machine.

Thanks for the report!

@joewiz
Copy link
Member

joewiz commented Jun 23, 2024

@Speedlearner5 eXide v3.5.3 has been released (GitHub Release, Public Repo), with a fix to the issue you reported - eXide's detection of Javascript and Markdown files in the editor pane (#695).

You can update eXide on your system by visiting eXist's Dashboard > Package Manager. After a moment, Package Manager will display any newer versions of your installed packages, and eXide should be among these. In the entry that should appear for eXide, click on the "⤓" (Download) icon to download and install the latest version of eXide. When you next open eXide, you may need to shift-click on your browser's reload button to ensure your browser loads the current copy of its resources.

@Speedlearner5
Copy link
Author

Speedlearner5 commented Jun 23, 2024

I updated the eXist software just like you recommended. Then I stopped the eXist server and started it again. The problem persists. It still won't recognize my javascript file as a javescript file and it won't recognize my xhtml file as a xhtml file. I decided to create my own xhtml file in Windows notepad and I saved it to my documents folder on my computer. Here is what I saved:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TedTheSpeedlearner.com SVG_Ellipse_Webpage_XML_Schema.xsd">
    <head>
        <title>SVG Ellipse</title>
        <link rel="stylesheet" type="text/css" href="http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Ellipse.css"/>
        <script language="javascript" src="http://localhost:8080/exist/rest/db/apps/HTML_Student/SVG_Ellipse.js"/>
    </head>
    <body onload="Setup()">
        <svg id="Image_Box">
            <ellipse id="My_Ellipse"/>
        </svg>
    </body>
</html>

When I opened this document, I saw a blank screen. I'm not sure what happened. I know one thing for sure. Whenever I try to save the document type declaration code in eXist and reload eXiide, the document type definition disappears. No matter how many times I save this code, it still disappears.

@joewiz
Copy link
Member

joewiz commented Jun 24, 2024

Re: eXide not recognizing your Javascript file as Javascript, please shift-click on your browser's reload button with the eXide window in front.

Re: the DocType not appearing when you reload your HTML file in eXide, this is a complex issue that depends both on how you save the document to the database and how you serialize it - and over what interface. eXide can factor into the equation too, since it has a serialization drop-down and numerous serialization-related preferences. Controlling the storage and serialization of doctypes and entities is an area ripe for user confusion in eXist and has been discussed and worked on extensively. You might peruse the list of issues mentioning "doctype" and try to assess whether your issue belongs to one of those or whether it is somehow unknown and needs a new issue. Whether you add your findings to an existing issue or start a new one, please provide steps for reproducing your results and complete all questions. If you start a new issue, please answer all questions in the issue template - eXist version, etc.

@adamretter
Copy link
Contributor

In case it is helpful to know - I added doctype support to eXist-db some time ago; since then there hasn't been a new release though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants