Element or attribute do not match QName production
Asked Answered
P

2

5

I have a schema that i have "flattened" using XML Editor. After i flatten it i get a validation error. What can i do to fix it?

Error Message:

F [Xerces] Element or attribute do not match QName production: QName::=(NCName':')?NCName.

code:

<xs:import namespace="http://www.opengis.net/gml"
    schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"
    xmlns:="http://www.opengis.net/gml/3.1.1" />
<xs:annotation xmlns:="http://www.opengis.net/sps/1.0">
    <xs:documentation>
        <copyright>                 SPS is an OGC Standard.                 Copyright (c)
            2007,2010 Open Geospatial Consortium, Inc. All Rights Reserved.                 To
            obtain additional rights of use, visit http://www.opengeospatial.org/legal/ .
        </copyright>
    </xs:documentation>
</xs:annotation>

Here's a screenshot that might better illustrate my error: enter image description here

EDIT:

Remove the colon somehow. What exactly does this "flattening" supposed to do?

The flattening of the xsd takes an xsd with a lot of includes and puts it all into one file (without any includes).

Pleurisy answered 31/1, 2011 at 15:28 Comment(2)
Remove the colon somehow. What exactly does this "flattening" supposed to do?Fibrinolysis
Removing the colon didn't work for me but see my edit about the flattening.Pleurisy
S
15

xmlns:= is invalid syntax. The colon is extra or the namespace prefix after the colon is missing. Correct syntax would be xmlns="http://some.uri" or xmlns:something="http://some.uri"

Note that you have 2 un-needed colons: first one on line 1002 (where the red arrow is pointing) and the second one is on the line 1003. This gives a hint that there might be even more of them.

"QName" refers to "qualified name" and "NCName" refers to "non-colonized name". Non-colonized name is an XML name that doesn't contain a colon character (:). Qualified name is either a non-colonized name or combination of two non-colonized names separated with a colon. For example "abc:defgh". The part before the colon is called the namespace prefix and the part after the colon is called the local name. If a qualified name has a namespace prefix, then that prefix must be bound to a namespace-URI with a prefixed namespace declaration, for example xmlns:abc="http://some.uri".

Subtraction answered 31/1, 2011 at 20:18 Comment(1)
I guess the flattening of the schema messes everything up because if i validate all the included files, it validates fine, but after it's flattened, it has these errors. I tried removing the colon on line 1002 then it gave me the error on line 1003. when i removed the one on 1003 it gives me more (just as you said there would be). After removing the final colon, many validation errors appear.Pleurisy
L
0

In case it's helpful to anyone else, I got the same error message and realized that what was causing it was the colon in the namespace URI, i.e. "http://whatever". I had been concatenating the namespace URI to the resources and properties directly rather than registering the namespace as a symbol, so a resource or a property might look like "http://hl7.org/fhir/:Observation", which of course has two colons and therefore does not follow the "QName::=(NCName':')?NCName" production format.

I fixed it by first registering the namespace with the model:

model.setNsPrefix("fhir","http://hl7.org/fhir/");

and then prepending the namespace in my resources and properties:

Resource root = model.getResource("fhir:Patient");
root.addProperty(model.createProperty("fhir:Patient.identifier"), patient.identifier);
Lindsylindy answered 25/5, 2019 at 16:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.