Hi Michael,
I have followed all the steps those you have discussed in your tutorial at 
http://developer.marklogic.com/howto/tutorials/2007-04-schema.xqy . I tested it 
and it is working fine as per your tutorial.
The problem is when change the tutorial.xml <born> field data from a valid date 
by a string, and then I load this tutorial.xml again into the database; this 
time it should not be loaded into the database because it is not the proper xml 
according the tutorial.xsd. But it is loaded successfully into the database. I 
mean to say while I load a new document then MarkLogic xml schema validation is 
not working.

Please help me out. What I need to do so that when I load a new xml file into 
the database then MarkLogic should validate it before loading ,and if it is not 
correct then MarkLogic should throw some error.

Regards, 
Anuj Kumar

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Michael Blakeley
Sent: Saturday, August 22, 2009 3:17 AM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] possible to use a xml schema withouta 
target namespace?

Nivaldo,

Namespaces are very useful when working with schemas. However, I find 
that this works: note that the root xs:schema element has no 
targetNamespace attribute.

(: in Schemas :)
xdmp:document-insert(
   'test.xsd',
<xs:schema
  attributeFormDefault="unqualified"
  elementFormDefault="unqualified"
  xmlns:xs="http://www.w3.org/2001/XMLSchema";
  xmlns="http://marklogic.com/tutorial";>
   <xs:element name="name" type="xs:token"
    abstract="false" nillable="false"/>
   <xs:element name="qualification" type="xs:token"
    abstract="false" nillable="false"/>
   <xs:element name="born" type="xs:date"
    abstract="false" nillable="false"/>
   <xs:element name="dead" type="xs:date"
    abstract="false" nillable="false"/>
   <xs:element name="isbn" type="xs:unsignedLong"
    abstract="false" nillable="false"/>
   <xs:attribute name="id" type="xs:ID"/>
   <xs:attribute name="available" type="xs:boolean"/>
   <xs:attribute name="lang" type="xs:language"/>
   <xs:element name="title" abstract="false" nillable="false">
     <xs:complexType mixed="false">
       <xs:simpleContent>
        <xs:extension base="xs:token">
          <xs:attribute ref="lang" use="optional"/>
        </xs:extension>
       </xs:simpleContent>
     </xs:complexType>
   </xs:element>
   <xs:element name="library" abstract="false" nillable="false">
     <xs:complexType mixed="false">
       <xs:sequence minOccurs="1" maxOccurs="1">
        <xs:element ref="book" maxOccurs="unbounded" minOccurs="1"/>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
   <xs:element name="author" abstract="false" nillable="false">
     <xs:complexType mixed="false">
       <xs:sequence minOccurs="1" maxOccurs="1">
        <xs:element ref="name" minOccurs="1" maxOccurs="1"/>
        <xs:element ref="born" minOccurs="1" maxOccurs="1"/>
        <xs:element ref="dead" minOccurs="0" maxOccurs="1"/>
       </xs:sequence>
       <xs:attribute ref="id" use="optional"/>
     </xs:complexType>
   </xs:element>
   <xs:element name="book" abstract="false" nillable="false">
     <xs:complexType mixed="false">
       <xs:sequence minOccurs="1" maxOccurs="1">
        <xs:element ref="isbn" minOccurs="1" maxOccurs="1"/>
        <xs:element ref="title" minOccurs="1" maxOccurs="1"/>
        <xs:element ref="author" minOccurs="0"
    maxOccurs="unbounded"/>
        <xs:element ref="character" minOccurs="0"
    maxOccurs="unbounded"/>
       </xs:sequence>
       <xs:attribute ref="id" use="optional"/>
       <xs:attribute ref="available" use="optional"/>
     </xs:complexType>
   </xs:element>
   <xs:element name="character" abstract="false" nillable="false">
     <xs:complexType mixed="false">
       <xs:sequence minOccurs="1" maxOccurs="1">
        <xs:element ref="name" minOccurs="1" maxOccurs="1"/>
        <xs:element ref="born" minOccurs="1" maxOccurs="1"/>
        <xs:element ref="qualification" minOccurs="1"
    maxOccurs="1"/>
       </xs:sequence>
       <xs:attribute ref="id" use="optional"/>
     </xs:complexType>
   </xs:element>
</xs:schema>
)

(: in content database :)
import schema ''
   at 'test.xsd';
xdmp:describe(data(<book available="0"/>/@available))
=> false()

Without the schema, the query would return xs:untypedAtomic("0"). Note 
that the 'import schema...' prologue declaration isn't strictly 
necessary, but might be helpful if you have more than one namespace-free 
schema in your Schemas database.

-- Mike

On 2009-08-21 13:31, Fernandes, Nivaldo wrote:
> Hi Michael,
>
> In your tutorial at 
> http://developer.marklogic.com/howto/tutorials/2007-04-schema.xqy you write:
> “Before we get started, there's one more thing we should know about XML 
> Schema and MarkLogic Server. They work best when our XML uses a default 
> element namespace. Schemas can have a target namespace, so setting a default 
> element namespace allows us to have multiple schemas, and automatically apply 
> the correct schema to the correct content.”
>
> Since you did not say it was NOT possible to use a schema without a target 
> namespace (sorry for the double negative), I looked it up in the Admin and 
> Developer’s guide for a way to do it…but could not find it (or perhaps it was 
> there and I did not see it). Could you clarify if is possible to make use of 
> a schema without a target namespace in ML 4.1 and if so, how?
>
> Thanks!
> Nivaldo
>


_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply 
e-mail and destroy all copies of the original message. 
Any unauthorised review, use, disclosure, dissemination, forwarding, printing 
or copying of this email or any action taken in reliance on this e-mail is 
strictly 
prohibited and may be unlawful.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to