From: Ted H. <meg...@gm...> - 2023-12-15 17:28:53
|
I finally understand most of what is going on here. The validation module is sort of like an object in object oriented programming. The clear grammar cache is like an object method. And the validation report is like an object method. I inserted the new line of code as everyone here has suggested. But I received a new error: 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:validate-report($instance, $schema)) Function validation:validate-report() is not defined in module namespace: http://exist-db.org/xquery/validation [at line 5, column 36] I'm guessing that this "method" doesn't exist in this module. Where does it exist? nction validation:validate-report() is not defined in module namespace: http://exist-db.org/xquery/validation [at line 5, column 36] Function validation:validate-report() is not defined in module namespace: http://exist-db.org/xquery/validation Function validation:validate-report() is not defined in module namespace: http://exist-db.org/xquery/validation On Thu, Dec 14, 2023 at 6:04 PM Michael Westbay < wes...@ja...> wrote: > Hi Ted, > > Let's first break down your program: > > xquery version "3.0"; >> 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:validate-report($instance, >> $schema)) >> > > The two *let* statements assign values to the variables *$schemai and > $instance*. So far, so good. > > Then you make two function calls in the *return* statement, these to: > > ・ *validation:clear-grammar-cache*() > ・ *validation:validate-report*(...) > > The *validation* namespace is NOT built into XQuery. It needs to be > loaded into your program. > > A quick check of the XQuery Function Documentation for "validation" ( > https://exist-db.org/exist/apps/fundocs/index.html) shows that the > namespace of *http://exist-db.org/xquery/validation > <http://exist-db.org/xquery/validation>* has the first function, but not > the second. The closest function to the second is the > *validation:jaxp-report/3* function: > > validation:jaxp-report > > validation:jaxp-report($instance as item(), $enable-grammar-cache as xs:boolean, $catalogs as item()*) as node() > > Validate document by parsing $instance. Optionally grammar caching can be > enabled and an XML catalog can be specified. Supported grammars types are > '.xsd' and '.dtd'. An XML report is returned. > Parameters: > $instance The document referenced as xs:anyURI, a node (element or result > of fn:doc()) or as a Java file object. > $enable-grammar-cache Set the flag to true() to enable grammar caching. > $catalogs* The catalogs referenced as xs:anyURI's.Returns:node() : a > validation report. > > > To import the *validation* namespace into your program, enter the > following after the XQuery version line: > > import module namespace "http://exist-db.org/xquery/validation"; > > > Importing modules is one of the core functionalities of XQuery for code > reuse. I strongly recommend reading this page about creating (and using) > XQuery functions from the XQuery WikiBook: > > https://en.wikibooks.org/wiki/XQuery/Creating_XQuery_Functions > > > That explains how to create your own modules and import them. The example > I provided above (which doesn't have the *at* clause) is for modules > built into eXist. > > The XQuery Function Documentation page and XQuery WikiBook are two > resources you should have bookmarked. > > Hope this helps. > > -- > Michael Westbay > Writer/System Administrator > http://www.japanesebaseball.com/ > |