Uploading XSD schemas with imported namespaces into Marklogic 6 -


as small excercise i'm trying upload , validate documents couple of schemas. these grow i'd keep them separate.

these example schemas define localized text string , food dish:

bitfood-common.xsd:

<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"   xmlns:bfc="http://bitfood.org/common"    targetnamespace="http://bitfood.org/common"   elementformdefault="qualified">    <xs:simpletype name="objectid">     <xs:restriction base="xs:string">       <xs:length value="24"/>       <xs:whitespace value="collapse"/>     </xs:restriction>   </xs:simpletype>    <xs:simpletype name="locale">     <xs:restriction base="xs:string">       <xs:length value="5"/>       <xs:whitespace value="collapse"/>     </xs:restriction>   </xs:simpletype>    <xs:complextype name="localizedtext">     <xs:attribute name="text" type="xs:string" use="required"/>     <xs:attribute name="locale" type="bfc:locale" use="required"/>   </xs:complextype> </xs:schema> 

bitfood-dish.xsd:

<xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"   xmlns:bfd="http://bitfood.org/dish"    xmlns:bfc="http://bitfood.org/common"   targetnamespace="http://bitfood.org/dish"    elementformdefault="qualified">    <xs:import namespace="http://bitfood.org/common"    schemalocation="../common/bitfood-common.xsd" />    <xs:element name="dish">     <xs:complextype>       <xs:sequence>         <xs:element name="name" type="bfc:localizedtext" maxoccurs="unbounded"/>         <xs:element name="description" type="bfc:localizedtext" maxoccurs="unbounded"/>       </xs:sequence>       <xs:attribute name="id" type="bfc:objectid" use="required"/>       <xs:attribute name="price" type="xs:decimal" use="required"/>       <xs:attribute name="imageurl" type="xs:anyuri" use="required"/>     </xs:complextype>   </xs:element> </xs:schema> 

i uploaded these 2 documents inside schemas database assigned xml database following uri id's:

schema/common/bitfood-common.xsd schema/dish/bitfood-dish.xsd 

and uploaded example document:

dish/520cc720c208c01ddfb75254.xml:

<?xml version="1.0" encoding="utf-8"?> <dish id="520cc720c208c01ddfb75254" price="35"        imageurl="foodcantongourrmettwodish.jpg"        xmlns="http://bitfood.org/dish">   <name text="example dish." locale="en-us"/>   <description text="localized text test." locale="en-us"/> </dish> 

when issue following command on server's query console, empty set when instruct database infer type of xml document's root node:

update: wrong node index, must 1 in case:

(: working? :) declare namespace bfd = "http://bitfood.org/dish"; declare namespace bfc = "http://bitfood.org/common"; xdmp:describe(data(   doc('dish/520cc720c208c01ddfb75254.xml')/bfd:dish[1] )) 

output:

<?xml version="1.0" encoding="utf-8"?> <results warning="atomic item">xs:untypedatomic("")</results> 

this means database either ignoring or not able find schema documents. also, not sure if can't apply schemas because of xs:import namespace statement.

has attempted work imported xsd documents marklogic in way? there may doing wrong?

update 2: seems can applied attributes. following command work expected, means schemas being detected:

(: working? :) declare namespace bfd = "http://bitfood.org/dish"; declare namespace bfc = "http://bitfood.org/common"; xdmp:describe(data(doc('dish/520cc720c208c01ddfb75254.xml')/bfd:dish[1]/@id)) 

thanks!

xquery positional predicates start @ 1 not 0. try this:

doc('dish/520cc720c208c01ddfb75254.xml')/bfd:dish[1]

then work way more complicated code.

-david lee


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -