Re: Still trying to validate an XML Schema
Alexander Henket <[email protected]> Tue, 18 Jun 2024 07:50:11 +0200
| Newsgroups | gmane.text.xml.exist |
|---|---|
| Message-ID | <[email protected]> |
Not sure if it hits what you ask, but there seems to be a syntax issue in the parentheses after return. And validate:jaxv will give me what I think you are after:
xquery version "3.0";
import module namespace validation="http://exist-db.org/xquery/validation";
let $schema := xs:anyURI('/db/apps/tmp/....xsd')
let $instance := xs:anyURI('/db/apps/tmp/....xml')
return (
validation:clear-grammar-cache(),
validation:jaxv-report($instance, $schema)
)
Yields:
0 <report><status>valid</status><duration unit="msec">4333</duration></report>
Note that the leading zero is from clear-grammar-cache(), and the xml bit is from jaxv-report. Depending on eXist-db or up, you might want to use xquery 3.1 instead of 3.0 too, but the above works in eXist-db 6.
Hope this helps
Regards
Alexander Henket
> Op 18 jun 2024, om 02:40 heeft Ted Hickox <[email protected]> het volgende geschreven:
>
> Perhaps I didn't make myself clear in my last post. It appears the Jaxp function that I added to my xq code worked well enough to detect an error. The problem is I don't know what error I created.
>
> Here is my xquery:
>
> xquery version "3.0";
> import module namespace validation="http://exist-db.org/xquery/validation";
> let $schema := xs:anyURI('/db/apps/HTML_Student/SVG_Ellipse_Webpage_XML_Schema.xsd')
> let $instance := xs:anyURI('/db/apps/HTML_Student/SVG_Ellipse_Webpage_XML.xml')
> return
> (validation:clear-grammar-cache())
> (validation:jaxp-report($instance, $schema))
>
> Here is my instance:
>
> <html xmlns="http://www.TedTheSpeedlearner.com <http://www.tedthespeedlearner.com/>" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TedTheSpeedlearner.com <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>
>
>
> And here is my schema:
>
> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:target="http://www.TedTheSpeedlearner.com <http://www.tedthespeedlearner.com/>" targetNamespace="http://www.TedTheSpeedlearner.com <http://www.tedthespeedlearner.com/>" elementFormDefault="qualified">
> <complexType name="HeadType">
> <sequence>
> <element name="head" type="target:TitleType"/>
> <element name="body" type="target:BodyType"/>
> </sequence>
> </complexType>
> <complexType name="TitleType">
> <sequence>
> <element name="title" type="string"/>
> <element name="link" type="target:LinkType"/>
> <element name="script" type="target:ScriptType"/>
> </sequence>
> </complexType>
> <complexType name="LinkType">
> <attribute name="rel" type="string"/>
> <attribute name="type" type="string"/>
> <attribute name="href" type="string"/>
> </complexType>
> <complexType name="ScriptType">
> <attribute name="language" type="string"/>
> <attribute name="src" type="string"/>
> </complexType>
> <complexType name="BodyType">
> <sequence>
> <element name="svg" type="target:SvgType"/>
> </sequence>
> <attribute name="onload" type="string"/>
> </complexType>
> <complexType name="SvgType">
> <sequence>
> <element name="ellipse" type="target:EllipseType"/>
> </sequence>
> <attribute name="id" type="string"/>
> </complexType>
> <complexType name="EllipseType">
> <attribute name="id" type="string"/>
> </complexType>
> <element name="html" type="target:HeadType"/>
> </schema>
>
> And what was the error? eXist stated that it expected a function, but it got an xs:integer in line 6 column 2. I can't determine what I did wrong. Can you assist me?
>
> On Tue, Jun 11, 2024 at 11:19 AM Florian Schmitt <[email protected] <mailto:[email protected]>> wrote:
>> Hi Ted,
>>
>> i'm not sure if it works with validation:jaxp-report, too, but i got a
>> simple example running with validation:jaxv-report. Schema and XML
>> instance are copied from the W3 Schools example:
>>
>> https://www.w3schools.com/xml/schema_intro.asp
>>
>> ------------------------------
>> schema.xsd:
>> ------------------------------
>> <?xml version="1.0"?>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>>
>> <xs:element name="note">
>> <xs:complexType>
>> <xs:sequence>
>> <xs:element name="to" type="xs:string"/>
>> <xs:element name="from" type="xs:string"/>
>> <xs:element name="heading" type="xs:string"/>
>> <xs:element name="body" type="xs:string"/>
>> </xs:sequence>
>> </xs:complexType>
>> </xs:element>
>>
>> </xs:schema>
>>
>> ------------------------------
>> note.xml:
>> ------------------------------
>> <note>
>> <to>Tove</to>
>> <from>Jani</from>
>> <heading>Reminder</heading>
>> <body>Don't forget me this weekend!</body>
>> </note>
>>
>> ------------------------------
>> schema-test.xq:
>> ------------------------------
>> xquery version "3.0";
>> import module namespace
>> validation="http://exist-db.org/xquery/validation";
>> let $schema := xs:anyURI('/db/xmldata/schema.xsd')
>> let $instance := xs:anyURI('/db/xmldata/note.xml')
>> return
>> (validation:clear-grammar-cache(), validation:jaxv-report($instance,
>> $schema))
>>
>> ------------------------------
>> Output (with eXist-db 5.2.0 - sorry, currently no 6.xx available:
>> ------------------------------
>> 0
>> <report>
>> <status>valid</status>
>> <duration unit="msec">13</duration>
>> </report>
>>
>> HTH
>> Florian
>>
>>
>> Am 09.06.24 um 21:41 schrieb Ted Hickox:
>> > I have a small update. I made a couple of changes to my code:
>> >
>> > xquery version "3.0";
>> > import module namespace
>> > validation="http://exist-db.org/xquery/validation
>> > <http://exist-db.org/xquery/validation>";
>> > let $schema :=
>> > xs:anyURI('/db/apps/HTML_Student/SVG_Ellipse_Webpage_XML_Schema.xsd')
>> > let $instance :=
>> > xs:anyURI('/db/apps/HTML_Student/SVG_Ellipse_Webpage_XML.xml')
>> > return
>> > (validation:clear-grammar-cache())
>> > (validation:jaxp-report($instance, $schema))
>> >
>> > This fixed a bunch of problems. But when I ran the code, I got this
>> > information:
>> >
>> > image.png
>> >
>> > I still don't know what error I made.
>> > eption>
>> > <path>/db/apps/HTML_Student/SVG_Ellipse_Webpage_XQuery_Validator.xq</path>
>> > <message>err:XPTY0004 Type error: expected function, got xs:integer
>> > [at line 6, column 2, source:
>> > /db/apps/HTML_Student/SVG_Ellipse_Webpage_XQuery_Validator.xq]</message>
>> > </exception>
>> >
>> > exception>exception>
>> > <path>/db/apps/HTML_Student/SVG_Ellipse_Webpage_XQuery_Validator.xq</path>
>> > <message>err:XPTY0004 Type error: expected function, got xs:integer
>> > [at line 6, column 2, source:
>> > /db/apps/HTML_Student/SVG_Ellipse_Webpage_XQuery_Validator.xq]</message>
>> > </exception>
>> > <path>/db/apps/HTML_Student/SVG_Ellipse_Webpage_XQuery_Validator.xq</path>
>> > <message>err:XPTY0004 Type error: expected function, got xs:integer
>> > [at line 6, column 2, source:
>> > /db/apps/HTML_Student/SVG_Ellipse_Webpage_XQuery_Validator.xq]</message>
>> > </exception>
>> >
>> > On Sun, Jun 9, 2024 at 1:58 PM Ted Hickox <[email protected] <mailto:[email protected]>
>> > <mailto:[email protected] <mailto:[email protected]>>> wrote:
>> >
>> > A few months ago I was informed that the function
>> > validation:validate-report had been depreciated and is no longer
>> > available in the eXist database. So someone suggested I use the
>> > validate:jaxp-report function. Shortly after I received this
>> > suggestion, I tried to use it. But it failed. Unfortunately my
>> > life became very busy and I had to abandon my project. Now that
>> > my life is a little calmer, I tried to play with this computer
>> > code again. And still something is not functioning correctly.
>> > I'm still not sure what I'm doing wrong.
>> >
>> > xquery version "3.0";
>> > import module namespace
>> > validation="http://exist-db.org/xquery/validation
>> > <http://exist-db.org/xquery/validation>";
>> > let $schema :=
>> > xs:anyURI('/db/apps/HTML_Student/SVG_Ellipse_Webpage_XML_Schema.xsd')
>> > let $instance :=
>> > xs:anyURI('/db/apps/HTML_Student/SVG_Ellipse_Webpage_XML.xml')
>> > return
>> > (validation:clear-grammar-cache();
>> > validation:jaxp-report($instance as item(), $enable-grammar-cache
>> > as xs:boolean, $catalogs as item()*) as node())
>> >
>> >
>> >
>> > _______________________________________________
>> > Exist-open mailing list
>> > [email protected] <mailto:[email protected]>
>> > https://lists.sourceforge.net/lists/listinfo/exist-open
>>
>>
>>
>> _______________________________________________
>> Exist-open mailing list
>> [email protected] <mailto:[email protected]>
>> https://lists.sourceforge.net/lists/listinfo/exist-open
> _______________________________________________
> Exist-open mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/exist-open
_______________________________________________
Exist-open mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/exist-open