title: Unable to validate XML against XSD schema
body: <p>I am working on a Python project where we have a function generating an XML Schema from data gathered from different sources. The main objective is not to validate the output of this function using an authoritative schema (namely <a href="https://github.com/ietf-tools/xml2rfc/blob/main/xml2rfc/data/v3.rnc" rel="nofollow noreferrer">https://github.com/ietf-tools/xml2rfc/blob/main/xml2rfc/data/v3.rnc</a>).</p>
  <p>The official authoritative schema is in Relax NG Compact (RNC) format. Thus, I converted this schema into an XSD schema using the <a href="https://relaxng.org/jclark/trang.html" rel="nofollow noreferrer">trang</a> official converter tool.</p>
  <p><a href="https://gist.github.com/stefanomunarini/952f676f4e7e967295d35c430cf059d5" rel="nofollow noreferrer">Here is the XSD Schema</a>.</p>
  <p>During conversion of the schema, the following warning message is shown:</p>
  <pre><code>xml2rfc/xml2rfc/data/v3.rnc:495:45: warning: cannot represent an optional group of attributes; approximating
  </code></pre>
  <p>Now, I used an <a href="https://www.utilities-online.info/xsdvalidation" rel="nofollow noreferrer">online validator</a> to validate the XSD obtained using trang, which confirms that XSD is syntactically correct.</p>
  <p>If, however, using the same tool I try to validate an XML file, the following error messages are raised:</p>
  <pre><code>- Element '{http://www.w3.org/2001/XMLSchema}attributeGroup', attribute 'ref': The QName value '{http://www.w3.org/XML/1998/namespace}base' does not resolve to a(n) attribute group definition.
  
  - Element '{http://www.w3.org/2001/XMLSchema}attributeGroup', attribute 'ref': The QName value '{http://www.w3.org/XML/1998/namespace}lang' does not resolve to a(n) attribute group definition.
  
  - Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'ref': The QName value '{http://www.w3.org/2000/svg}svg' does not resolve to a(n) element declaration.
  </code></pre>
  <p>Same thing happens when I try to parse the XSD schema using the <a href="https://lxml.de" rel="nofollow noreferrer">lxml</a> python library.</p>
  <p>Does anyone have any idea how these issues can be addressed?</p>