Custom XML Content Validation

(Difference between revisions)
Jump to: navigation, search
(escaping angle brackets in xsd example)
(restoring brackets for code tag)
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>
+
<code>
 
   &lt;xsd:annotation&gt;
 
   &lt;xsd:annotation&gt;
 
     &lt;xsd:appinfo&gt;
 
     &lt;xsd:appinfo&gt;
Line 10: Line 10:
 
     &lt;/xsd:appinfo&gt;
 
     &lt;/xsd:appinfo&gt;
 
   &lt;/xsd:annotation&gt;
 
   &lt;/xsd:annotation&gt;
&lt;/code&gt;
+
</code>
  
 
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 17:52, 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:

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

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