Node Insertion through XQJ and XSD Validation

Friday, 6 December 2013 · 2 messages
AR
Ando Roy6 Dec 2013 06:56 #

Greetings,

I've just started reading through the materials on XQJ and would like to ask the following:

Let's say I have a simple XML file (I'll use the W3Schools Xquery tutorial):

1. Can I have an example query of how I could insert another book node into this file? 2. If I would like to perform schema validation through XSD, how should I change the code? - eg. (if I have set the maxOccurs attribute set as 1), will XQJ throw some exception?

<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
</bookstore>

Regards, Roy

CG
Christian Grün6 Dec 2013 12:51 #

Hi Ando,

Quoted text · Ando Roy · 2 lines
> 1. Can I have an example query of how I could insert another book node into > this file?

XQuery Update will help you here [1]:

insert node <book>...</book> into /bookstore

Quoted text · Ando Roy · 4 lines
> 2. If I would like to perform schema validation through XSD, how should I > change the code? > - eg. (if I have set the maxOccurs attribute set as 1), will XQJ throw some > exception?

The functions of the BaseX Validation Module [2] can be used to validate XML documents and nodes.

Hope this helps, Christian

[1] http://docs.basex.org/wiki/XQuery_Update [2] http://docs.basex.org/wiki/Validation_Module

Quoted text · Ando Roy · 18 lines
> > <bookstore> > <book category="COOKING"> > <title lang="en">Everyday Italian</title> > <author>Giada De Laurentiis</author> > <year>2005</year> > <price>30.00</price> > </book> > </bookstore> > > Regards, > Roy > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >

⚡Generated with XQuery