Jump to content

pottmi

Members
  • Content Count

    5
  • Joined

  • Last visited

Everything posted by pottmi

  1. Cool. Learned two cool things:I read about the anyAttribute, but I did not understand why I would want to use it ( I thought it was too liberal). now I know how I can use it.Also, the ref attribute. that makes more sense than the name/type combination that I was using.Here is my current problem, as an academic exercise, I am trying to limit the the attributes to href and type.Here is the schema I am using: <?xml version="1.0" ?><xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/2000/10/xlink-ns"> <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element ref="homepage"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="homepage"> <xs:complexType> <xs:attribute ref="xlink:type" use="optional" default="simple"/> <xs:attribute ref="xlink:href"/> </xs:complexType> </xs:element></xs:schema> Here is the errors I am getting:# pottmi@mikepb $ xmllint --schema myxlink.xsd --noout myxlink.xmlmyxlink.xsd:16: element attribute: Schemas parser error : Attribute ref. 'xlink:href', attribute 'ref': The QName value {'http://www.w3.org/2000/10/xlink-ns', 'href'} does not resolve to a(n) attribute declaration.myxlink.xsd:15: element attribute: Schemas parser error : Attribute ref. 'xlink:type', attribute 'ref': The QName value {'http://www.w3.org/2000/10/xlink-ns', 'type'} does not resolve to a(n) attribute declaration.myxlink.xsd:15: element attribute: Schemas parser error : Internal error: xmlSchemaCheckAttrValConstr, type is missing... skipping validation of value constraintWXS schema myxlink.xsd failed to compileI am sure that this is some stupid newbie error, but it is not obvious to me.The anyAttribute method is definitely better than this, I am just following thru to try to get a better understanding of XML.Thanks for all of your thoughtful answers. I am learning a lot.-- Mr. Potter
  2. Let me ask an explicite question:How do a modify this schema: <?xml version="1.0" ?><xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema"> <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="homepage" type="homepage"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="homepage"> <xs:complexType> <xs:attribute name="xml:lang" /> </xs:complexType> </xs:element></xs:schema> Such that this xml is valid: <?xml version="1.0"?><person><homepage xml:lang = "en" /></person> This is the error that I get when I try to validate it:# pottmi@mikepb $ xmllint --schema myxmllang.xsd --noout myxmllang.xmlmyxmllang.xsd:14: element attribute: Schemas parser error : Attribute decl., attribute 'name' ['NCName']: The value 'xml:lang' is not valid.WXS schema myxmllang.xsd failed to compile-- Mr. Potter
  3. I think what you are telling me that parsers do not have to enforce the xml: namespace being confined a limited number of keywords and that explains why xmllint allows xml:foobar to pass without an error.So what is wrong with my schema that it does not allow me to add an attribute xml:lang?I am sure it is something I am doing; I am relatively new to writing schemas.Mr. Potter
  4. I am trying to define a schema that includes xml:lang. I can add xml:lang to a dtd and it will pass xmllint, but I suspect I could add xml:foobar and it would pass xmllint.Please help me add xml:lang to both a dtd and schema. here is my test code:# pottmi@mikepb $ xmllint --schema myxmllang.xsd --noout myxmllang.xmlmyxmllang.xsd:14: element attribute: Schemas parser error : Attribute decl., attribute 'name' ['NCName']: The value 'xml:lang' is not valid.WXS schema myxmllang.xsd failed to compile# pottmi@mikepb $ xmllint --dtdvalid myxmllang.dtd --noout myxmllang.xml# pottmi@mikepb $ myxmllang.dtd: <!ELEMENT homepage (#PCDATA)> <!ATTLIST homepage xml:lang CDATA #REQUIRED> <!ELEMENT person (homepage)>myxmllang.xml:<?xml version="1.0"?><person><homepage xml:lang = "en" /></person><?xml version="1.0" ?><xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema"> myxmllang.xsd <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="homepage" type="homepage"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="homepage"> <xs:complexType> <xs:attribute name="xml:lang" /> </xs:complexType> </xs:element></xs:schema>
  5. I am trying to write a schema that contains an xlink. I was able to write a DTD successfully.Please tell me what I am doing wrong...myxlink.xml:<?xml version="1.0"?><person xmlns:xlink="http://www.w3.org/1999/xlink"><homepage'>http://www.w3.org/1999/xlink"><homepage xlink:href = "my.homepage.not" /></person>myxlink.dtd: <!ELEMENT homepage (#PCDATA)> <!ATTLIST homepage xlink:type (simple) #FIXED 'simple' xlink:href CDATA #REQUIRED> <!ELEMENT person (homepage)> <!ATTLIST person xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">myxlink.xsd:<?xml version="1.0" ?><xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/2000/10/xlink-ns"> <xs:import namespace="http://www.w3.org/2000/10/xlink-ns"/> <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="homepage" type="homepage"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="homepage"> <xs:complexType> <xs:attribute name="type" type="xlink:type" use="optional" default="simple"/> <xs:attribute name="href" type="xlink:href"/> </xs:complexType> </xs:element></xs:schema># pottmi@mikepb $ xmllint --dtdvalid myxlink.dtd --noout myxlink.xml# pottmi@mikepb $ xmllint --schema myxlink.xsd --noout myxlink.xmlmyxlink.xsd:18: element attribute: Schemas parser error : Attribute decl. 'href', attribute 'type': The QName value {'http://www.w3.org/2000/10/xlink-ns', 'href'} does not resolve to a(n) simple type definition.myxlink.xsd:17: element attribute: Schemas parser error : Attribute decl. 'type', attribute 'type': The QName value {'http://www.w3.org/2000/10/xlink-ns', 'type'} does not resolve to a(n) simple type definition.myxlink.xsd:10: element element: Schemas parser error : Element decl. 'homepage', attribute 'type': The QName value {'homepage'} does not resolve to a(n) type definition.myxlink.xsd:17: element attribute: Schemas parser error : Internal error: xmlSchemaCheckAttrValConstr, type is missing... skipping validation of value constraintWXS schema myxlink.xsd failed to compile# pottmi@mikepb $
×
×
  • Create New...