Validation Module

Monday, 25 June 2012 · 5 messages
SG
Seenivasan Gunabalan25 Jun 2012 10:07 #
Hi all, I am trying to validate an incoming xml post message against an xsd stored inside the basex. But I am getting this error [FODC0002] Resource 'sampledb/xsd/match.xsd' does not exist. I am sure the path is correct and the xsd file exists there. May I know where I am going wrong?
try {
      let $doc := |<simple:||root|
|xmlns:simple=||'http://basex.org/simple'||/>|
      return validate:xsd($doc,'sampledb/xsd/match.xsd')

} catch BXVA0001 {
   'Validation failed.'
}
Thanks in advance.
SG
Seenivasan Gunabalan25 Jun 2012 10:49 #
Quoted text · Seenivasan Gunabalan · 18 lines
On 06/25/2012 10:07 AM, Seenivasan Gunabalan wrote: > Hi all, > I am trying to validate an incoming xml post message > against an xsd stored inside the basex. But I am getting > this error [FODC0002] Resource 'sampledb/xsd/match.xsd' does not exist. > I am sure the path is correct and the xsd file exists there. May I > know where I am going wrong? > > try { > let $doc := |<simple:||root| > |xmlns:simple=||'http://basex.org/simple'||/>| > return validate:xsd($doc,'sampledb/xsd/match.xsd') > > } catch BXVA0001 { > 'Validation failed.' > } > > Thanks in advance.
I found one mistake at my side. I stored .xsd file as of RAW format type. It worked, when I changed it in to .XML format type and restructured my code like this
try {
          let $doc := |<simple:||root|
|xmlns:simple=||'http://basex.org/simple'||/>|
          let $schema := fn:doc('sampledb/xsd/match.xsd')
          return validate:xsd($doc,$schema)
}  catch BXVA0001 {
         'Validation failed.'
}
But still my question is, how to validate by just passing the path of .xsd rather than fetching using fn:doc() and passing it as an parameter of type node()?. Thanks.
CG
Christian Grün25 Jun 2012 11:34 #
Hi Seenivasan.
Quoted text · Seenivasan Gunabalan · 2 lines
> But I am getting > this error [FODC0002] Resource 'sampledb/xsd/match.xsd' does not exist.
The path is resolved relative to your working directory and not the database. If you want to match it against a schema stored in the database, you must indeed use functions like db:open() or doc(). Hope this helps, Christian
Quoted text · Seenivasan Gunabalan · 41 lines
> I am sure the path is correct and the xsd file exists there. May I know > where I am going wrong? > > try { > let $doc := <simple:root xmlns:simple='http://basex.org/simple'/> > return validate:xsd($doc,'sampledb/xsd/match.xsd') > > } catch BXVA0001 { > 'Validation failed.' > } > > Thanks in advance. > > > > I found one mistake at my side. I stored .xsd file as of RAW format type. It > worked, when I changed it in to .XML format type and restructured my code > like this > > > try { > let $doc := <simple:root xmlns:simple='http://basex.org/simple'/> > let $schema := fn:doc('sampledb/xsd/match.xsd') > return validate:xsd($doc,$schema) > } catch BXVA0001 { > 'Validation failed.' > } > > But still my question is, how to validate by just passing the path of .xsd > rather than fetching using fn:doc() and passing it as an parameter of type > node()?. > > Thanks. > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
SG
Seenivasan Gunabalan25 Jun 2012 13:20 #
Quoted text · Christian Grün · 55 lines
On 06/25/2012 11:34 AM, Christian Grün wrote: > Hi Seenivasan. > >> But I am getting >> this error [FODC0002] Resource 'sampledb/xsd/match.xsd' does not exist. > The path is resolved relative to your working directory and not the > database. If you want to match it against a schema stored in the > database, you must indeed use functions like db:open() or doc(). > > Hope this helps, > Christian > > > >> I am sure the path is correct and the xsd file exists there. May I know >> where I am going wrong? >> >> try { >> let $doc := <simple:root xmlns:simple='http://basex.org/simple'/> >> return validate:xsd($doc,'sampledb/xsd/match.xsd') >> >> } catch BXVA0001 { >> 'Validation failed.' >> } >> >> Thanks in advance. >> >> >> >> I found one mistake at my side. I stored .xsd file as of RAW format type. It >> worked, when I changed it in to .XML format type and restructured my code >> like this >> >> >> try { >> let $doc := <simple:root xmlns:simple='http://basex.org/simple'/> >> let $schema := fn:doc('sampledb/xsd/match.xsd') >> return validate:xsd($doc,$schema) >> } catch BXVA0001 { >> 'Validation failed.' >> } >> >> But still my question is, how to validate by just passing the path of .xsd >> rather than fetching using fn:doc() and passing it as an parameter of type >> node()?. >> >> Thanks. >> >> >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>
Thanks Christian. I have one more question to ask, will validate support validating xml against complex xsd?. I mean xsd importing many other xsds. I have one main xsd that import another 3 xsds. All these xsd were stored inside the database at sampledb/xsd/ And I am passing the root xsd as accessed by doc() function to the validate function. I am getting this error Validation failed: src-resolve: Cannot resolve the name ' 'type definition' component. Thanks.
CG
Christian Grün25 Jun 2012 16:46 #
Dear Seenivasan, please note that BaseX is mainly an XQuery Processor. As the stylesheet will be transformed by another processor (either Java’s or Saxon’s XSLT implementation), it won‘t be possible to include files in the transformation that are stored in the database. Instead, you can try to extract all required files to a local directory (e.g. your working directory, or a temporary directory) and apply xslt from there. As you may know, the extraction of files can all be done in XQuery, using the DB and File Modules. Hope this helps, Christian
Quoted text · Seenivasan Gunabalan · 83 lines
On Mon, Jun 25, 2012 at 1:20 PM, Seenivasan Gunabalan <seenivasan.gunabalan at dedalus.eu> wrote: > On 06/25/2012 11:34 AM, Christian Grün wrote: >> >> Hi Seenivasan. >> >>> But I am getting >>> this error [FODC0002] Resource 'sampledb/xsd/match.xsd' does not exist. >> >> The path is resolved relative to your working directory and not the >> database. If you want to match it against a schema stored in the >> database, you must indeed use functions like db:open() or doc(). >> >> Hope this helps, >> Christian >> >> >> >>> I am sure the path is correct and the xsd file exists there. May I know >>> where I am going wrong? >>> >>> try { >>> let $doc := <simple:root xmlns:simple='http://basex.org/simple'/> >>> return validate:xsd($doc,'sampledb/xsd/match.xsd') >>> >>> } catch BXVA0001 { >>> 'Validation failed.' >>> } >>> >>> Thanks in advance. >>> >>> >>> >>> I found one mistake at my side. I stored .xsd file as of RAW format type. >>> It >>> worked, when I changed it in to .XML format type and restructured my code >>> like this >>> >>> >>> try { >>> let $doc := <simple:root >>> xmlns:simple='http://basex.org/simple'/> >>> let $schema := fn:doc('sampledb/xsd/match.xsd') >>> return validate:xsd($doc,$schema) >>> } catch BXVA0001 { >>> 'Validation failed.' >>> } >>> >>> But still my question is, how to validate by just passing the path of >>> .xsd >>> rather than fetching using fn:doc() and passing it as an parameter of >>> type >>> node()?. >>> >>> Thanks. >>> >>> >>> >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>> > Thanks Christian. > > I have one more question to ask, will validate support validating xml > against complex xsd?. I mean xsd importing many other xsds. I have one main > xsd that import another 3 xsds. > All these xsd were stored inside the database at > > sampledb/xsd/ > > And I am passing the root xsd as accessed by doc() function to the validate > function. > > > I am getting this error > > Validation failed: src-resolve: Cannot resolve the name ' 'type definition' > component. > > Thanks. >

⚡Generated with XQuery