Jump to content

MatthewRed

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About MatthewRed

  • Rank
    Newbie
  1. Schema Tutorial and Reference

    Further "Scheme" is a LISP-like language which is worlds apart from what an XML Schema is.There is no Microsoft vs. W3C variations. Microsoft has a validating XML parser called MSXML that is compliant to the W3C standards regarding XML and Schema. I don't know what other XML related stuff it can do, since I don't use it.When working with XML Schema's, care should be taken as to what is parsing your data, some XML parsers do not validate, so none of this Schema stuff will do you any good in those cases.
  2. References across namespaces

    I have a first schema with a unique targetNamespace, a default namespace that of "http://www.w3.org/2001/XMLSchema",'>http://www.w3.org/2001/XMLSchema", and a global element "<element name="X"/>".The purpose of the first schema is simply to define some base element types. It's imported by a bunch of other schemas.I have a second schema, it too has a unique targetNamespace and a default namespace of "http://www.w3.org/2001/XMLSchema" that imports the first and its namespace. I also have a prefix qualified with the first schema's targetNamespace. Within the second, I reference X "<element ref="first:X"/>".The purpose of the second is to define types that are much more specific to a job. It too is imported by a bunch of schemas that are like the third described below.I have a third schema, which does this all again, and my xml file is validated against this. The purpose of this third is to describe elements specific to the xml file and more importantly the STRUCTURE of the root element of the xml file.I didn't choose this hierarchy, thats how it is in the production code.My problem is that the second element gets the error message about the first: "Message: Element must have a name or a ref attribute - element ignored". Did I qualify the reference wrong? Can anyone see the problem with my logic? Here are the example files:Three.xml--<?xml version="1.0" encoding="UTF-8"?><Three_Root xmlns="http://www.company.com/Three.xsd"targetNamespace="http://www.company.com/Three.xsd"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.company.com/Three.xsd Three.xsd"> <X>7</X></Three_Root>Three.xsd--<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema"xmlns:Three_ns="http://www.company.com/Three.xsd"xmlns:Two_ns="http://www.company.com/Two.xsd"targetNamespace="http://www.company.com/Three.xsd"> <import schemaLocation="Two.xsd" namespace="http://www.company.com/Two.xsd"/> <element name="Three_Root"> <complexType> <sequence> <element ref="Two_ns:X"/> </sequence> </complexType> </element></schema>Two.xsd--<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema"xmlns:Two_ns="http://www.company.com/Two.xsd"xmlns:One_ns="http://www.company.com/One.xsd"targetNamespace="http://www.company.com/Two.xsd"> <import schemaLocation="One.xsd" namespace="http://www.company.com/One.xsd"/> <element ref="One_ns:X"/></schema>One.xsd--<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://www.w3.org/2001/XMLSchema"xmlns:One_ns="http://www.company.com/One.xsd"targetNamespace="http://www.company.com/One.xsd"> <element name="X" type="integer"/></schema>
  3. Question about where namespaces have to match...

    Xerces, by Apache is an adequate solution to parsing an xml file into a DOM. It supports validation. Take apart the DOMPrint example and it demonstrates a simple solution.
  4. Multiple declaration issue

    Hey there,I have three schema files, One, Two, and Three. One has <xs:include schemaLocation="/path/here..."/> elements to include Two and Three. Each has a definition for a simple element X, Y and Z.My error is that I get a message akin to this: "Global element:'X' declared more than once". Now, I figure that One shouldn't have X, Y, or Z declared in it because they already exist in Two and Three. But can I get away with Two and Three both having those elements declared? Will that still cause a redefinition error? My initial testing suggests yes, but I could also be an idot.I have only limited ability to modify these schemas (the include hierarchy has to stay intact if I can help it), as they are already in the production enviroment, but any suggestion will be helpful.Thank you.
  5. attributes of the same value

    Yeah, ignore this. A long day and a stupid question.
  6. Question about where namespaces have to match...

    So aparently there is a seperate application of sorts I need to aquire to validate my xml file against my schema, a "schema validator". Does anyone know of one I can integrate into a c++ application?
  7. DOM and Schemas

    I have been converting config and definition files (company proprietary formats) to XML and xsd formats. We are using Qt 4.1.4 which has a Core Level 1 and 2 compliant DOM parser.How is xml validated against the xsd file? Is there something I'm suppost to do to test my data against the schema? How do I catch an error? How do I know it passed?I've played with some example data and schema, and I tried to get an error by breaking the schema file. This had no effect, and the xml file was parsed into a DOM tree regardless.I'm so confused, can anyone help me?
  8. Hey there,My company uses a *somewhat* xml and schema liike format for many of their data and configuration files. It is my task to write a converter to valid and qualified xml and xsd files.My question (premise): looking within the xml files (under Referencing a Schema in an XML Document), there is a part "<note xmlns="http://www.w3schools.com"".'>http://www.w3schools.com"". I understand that this is the namespace which the root element, and all child elements operate under. Further, there is a "xsi:schemaLocation="http://www.w3schools.com" attribute. Note that these are only relevant code fragments.Further, within the schema there is a "targetNamespace="http://www.w3schools.com"" and a "xmlns="http://www.w3schools.com"" set of attributes within the root element of the schema file (all this stuff is taken from the link above).My question (actual): which of these need to match? I am not abundantly clear what the default namespace in the schema file is for, or the default namespace expressed in the schemaLocation attribute, w3schools doesn't explain it too clearly and I cannot yet find a clear reference on the subject.Thanks in advance-
×