marklogic - Schema Validation of XHTML field -


i have xml entity this,

a:news-article xmlns:c="http://abc/core" xmlns:f="http://abc/fields" xmlns:a="http://abc/assets" xmlns:r="http://abc/refdata">   <c:id>xyz</c:id>   <c:type>asset</c:type>   <c:created-on>2016-03-17t08:26:27.764z</c:created-on>   <c:released-on>1985-11-03t00:00:00z</c:released-on>   <c:expires-on>2009-12-12t00:00:00z</c:expires-on>   <f:short-headline>     <c:content><c:l10n xml:lang="en">     <p>       carbide technology south korean project     </p>       </c:l10n></c:content>     <c:resources/>   </f:short-headline> </a:news-article> 

in xml, xhtml field. need validate such xhtml fields using schema validation. i.e. if provided empty value should throw schema validation error.

you need separate schemas each namespace.

in xsd "http://abc/core" namespace might want pattern check if content of element non-empty:

    <xs:element name="id">             <xs:simpletype>                 <xs:restriction base="xs:string">                     <xs:pattern value="\s+"/>                 </xs:restriction>             </xs:simpletype>     </xs:element> 

you need import schema "root" schema (in example assume "a:" prefix represents root schema) this:

<xs:import namespace="http://abc/core" 

schemalocation="core.xsd"/>

and reference element foreign namespace in right location:

    <xs:element name="authors">         <xs:complextype>           <xs:sequence>news-article             <xs:element ref="c:id"/>             <xs:element ref="c:type"/>             <!-- ... -->           </xs:sequence>         </xs:complextype>      </xs:element> 

if want make sure p element non empty need write schema of own, following same pattern above - declare non-empty pattern p , refer in schema c:l10n element.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -