how to implement custom schema ?

hi, i m practicing with nuxeo sdk and try to register a new schema like explained here http://doc.nuxeo.com/display/NXDOC/Document+types.

Unfortunatly, each time, i encounter the following error :

ERROR [org.nuxeo.ecm.core.schema.XSDLoader] FatalError: Premature end of file.
ERROR [org.nuxeo.ecm.core.schema.TypeService] org.xml.sax.SAXParseException: Premature end of file.

and the schema file became totaly empty.

Did i miss something ?

0 votes

1 answers

3455 views

ANSWER

Can you post the contents of your contribution file?
02/01/2012

Here's the last try :

– sample.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://project.nuxeo.org/sample/schemas/sample/">
  <xs:element name="sample1" type="xs:string"/>
  <xs:element name="sample2" type="xs:string"/>
</schema>

–contrib.xml

<?xml version="1.0"?>
<component name="org.nuxeo.sample.CustomType" version="1.0">

   <implementation class="org.nuxeo.sample.CustomType" />

  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
    <schema name="sample" src="schemas/sample.xsd" prefix="smpi" />
  </extension>
</component>
02/01/2012

Did you see your <xs:schema> item is not closed ?
02/01/2012

no, but i guess it's closed by </schema><br /> <xs:schema…..>….</schema>
02/01/2012

This is invalid XML. Please use a XML editor and validator to write XML, don't write it by hand.
02/01/2012



You need to close the tag with the namespace prefix as well as schema as bjalon pointed out. For example

<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.nuxeo.org/dam/schemas/dam/"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:nxs="http://www.nuxeo.org/dam/schemas/dam/">
  <xs:element name="client" type="xs:string" />
  <xs:element name="brandMake" type="xs:string" />
  <xs:element name="productModel" type="xs:string" />
</xs:schema>
1 votes



thank you, so i just closed the schema like you did, double check the file…and still have the same error.
02/01/2012

Then your file is still not valid XML. We can't help you without seeing the exact file (use pastebin.com for instance to show it to us), and anyway you should be able check by yourself that the XML is valid or not, there are many many tools to do it.
02/01/2012

Finally, i should have checked the file one more time. it's working now with the closing </xs:schema>.
02/01/2012