confusing messages about `type` from xmllint when trying RELAX NG pattern facet

19 Views Asked by At

I'm still learning RELAX NG, and some input requires me to check the data content with a pattern. After searching the web I tried this (fragment, modeled after the example in The Simplest Possible Pattern Facets):

  <define name="DT.Test">
    <a:documentation>Data Type: test</a:documentation>
    <data type="string">
      <param name="pattern">"[0-9]+"</param>
    </data>
  </define>

However when running xmllint using that, I got an error message saying:

element data: Relax-NG parser error : Type library 'http://relaxng.org/ns/structure/1.0' does not allow type parameters

So I removed the type parameter and tried again with this definition:

  <define name="DT.Test">
    <a:documentation>Data Type: test</a:documentation>
    <data>
      <param name="pattern">"[0-9]+"</param>
    </data>
  </define>

Astonishingly the message was:

element data: Relax-NG parser error : data has no type

So it seems xmllint is unhappy with both: Specifying a typeattribute, and not specifying one. I'm confused.

Appendix

Version of xmllint

> xmllint --version
xmllint: using libxml version 20904
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib Lzma
1

There are 1 best solutions below

0
U. Windl On

Still I don't quite understand the messages, but adding a datatypeLibrary attribute to the data element makes xmllint happy:

  <define name="DT.Test">
    <a:documentation>Data Type: Test</a:documentation>
    <data datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
          type="string">
      <param name="pattern">"[0-9]+"</param>
    </data>
  </define>