Custom XML Content Validation

(Difference between revisions)
Jump to: navigation, search
 
(escaping angle brackets in xsd example)
Line 3: Line 3:
 
The default regex based validation for XML contents can be replaced by a custom validation since OpenCms 6.0. In order to do that, you need to specify your own XML content handler class in the XSD like this:
 
The default regex based validation for XML contents can be replaced by a custom validation since OpenCms 6.0. In order to do that, you need to specify your own XML content handler class in the XSD like this:
  
<code>
+
&lt;code&gt;
   <xsd:annotation>
+
   &lt;xsd:annotation&gt;
     <xsd:appinfo>
+
     &lt;xsd:appinfo&gt;
       <handler class="my.own.XmlContentHandlerImplementationClassNameGoesHere" />
+
       &lt;handler class="my.own.XmlContentHandlerImplementationClassNameGoesHere" /&gt;
 
       ... Other nodes as required ...
 
       ... Other nodes as required ...
     </xsd:appinfo>
+
     &lt;/xsd:appinfo&gt;
   </xsd:annotation>
+
   &lt;/xsd:annotation&gt;
</code>
+
&lt;/code&gt;
  
 
A handler needs to implement the org.opencms.xml.content.I_CmsXmlContentHandler interface.
 
A handler needs to implement the org.opencms.xml.content.I_CmsXmlContentHandler interface.

Revision as of 18:50, 4 June 2007

Alexander Kandzior, Alkacon member/founder wrote on the OpenCms Developers List (opencms-dev@opencms.org):

The default regex based validation for XML contents can be replaced by a custom validation since OpenCms 6.0. In order to do that, you need to specify your own XML content handler class in the XSD like this:

<code>

 <xsd:annotation>
   <xsd:appinfo>
      <handler class="my.own.XmlContentHandlerImplementationClassNameGoesHere" />
      ... Other nodes as required ...
    </xsd:appinfo>
 </xsd:annotation>

</code>

A handler needs to implement the org.opencms.xml.content.I_CmsXmlContentHandler interface.

In case you need only special validation, it's a good idea to extend the default content handler and override only the required method, like this:

Invalid language.

You need to specify a language like this: <source lang="html">...</source>

Supported languages for syntax highlighting:

actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp, cpp-qt, csharp, css, d, delphi, diff, div, dos, eiffel, fortran, freebasic, gml, groovy, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, matlab, mirc, mpasm, mysql, nsis, objc, ocaml, ocaml-brief, oobas, oracle8, pascal, perl, php, php-brief, plsql, python, qbasic, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, z80

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox