For this, generally XML attributes are not namespaced.  If you want them to
be namespaced you have to explicitly set either
attributeFormDefault="qualified" in the schema root or form="qualified" in
the attribute definition.  Then you have to add a namespace prefix to the
attribute reference in your document.

These work:
<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema targetNamespace="http://carfax.org.uk/namespace";
        xmlns:tns="http://carfax.org.uk/namespace";
        attributeFormDefault="qualified"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <xsd:complexType name="sthType">
    <xsd:attribute name="foo" type="xsd:string"/>
  </xsd:complexType>
  <xsd:element name="something" type="tns:sthType"/>
</xsd:schema>

<?xml version="1.0" encoding="UTF-8"?>
<something xmlns:ns="http://carfax.org.uk/namespace";
           xmlns="http://carfax.org.uk/namespace";
           ns:foo="bar">
</something>

If you read the original document with this schema you'll get an
unrecognized attribute error, and vice-versa.

Peter

On Sat, May 16, 2015 at 9:40 AM, Hugo Mills <h...@carfax.org.uk> wrote:

>    The only concern I have, which is more likely to be a basic XML
> question than a PyXB-specific one, is that only the elements in the
> schema are namespaced, not the attributes, with the exception of the
> xsd:targetNamespace attribute. I can't get pyxbgen to run with xsd:
> namespaces on the attributes of the schema, nor with the xsd:
> namespace missing from the xsd:targetNamespace attribute. This
> confuses me somewhat, in my primitive understanding of XML Schema.
>
>    What am I doing wrong in all of this?
>
>    Thanks,
>    Hugo.
>
> --
> Hugo Mills             | The problem with programmers and the law is not
> that
> hugo@... carfax.org.uk | they treat laws as code, but that they don't
> http://carfax.org.uk/  | understand the VM it runs on.
> PGP: E2AB1DE4          |
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> pyxb-users mailing list
> pyxb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyxb-users
>
>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
pyxb-users mailing list
pyxb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyxb-users

Reply via email to