What is wrong with my schema?
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 3
- Joined: Mon Feb 07, 2005 11:37 pm
What is wrong with my schema?
xml:
and the schema (automaticaly generated, I only added targetNamespace="...")
If I try to validate the schema, I get this:
I don't understand what the validator wants from me
thanks
tom
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<data xmlns="http://www.example.net/test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.net/test test.xsd">
<foo>dfgsdgf</foo>
<bar>blabla</bar>
</data>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://www.example.net/test">
<xs:element name="data">
<xs:complexType>
<xs:sequence>
<xs:element ref="foo"/>
<xs:element ref="bar"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="foo" type="xs:NCName"/>
<xs:element name="bar" type="xs:NCName"/>
</xs:schema>
and if I try to validate the xml, I get this:src-resolve.4.1: Error resolving component 'foo'. It was detected that 'foo' has no namespace, but components with no target namespace are not referenceable from schema document 'file:/D:/eclipse/workspace/test/test.xsd'. If 'foo' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'foo' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:/D:/eclipse/workspace/test/test.xsd'.
@see: http://www.w3.org/TR/xmlschema-1/#src-resolve
What am I doing wrong?cvc-complex-type.2.4.d: Invalid content was found starting with element 'foo'. No child element is expected at this point.
@see: http://www.w3.org/TR/xmlschema-1/#cvc-complex-type
I don't understand what the validator wants from me

thanks
tom
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Yes, target namespace and default namespace can be different in a schema, your schema for instance.
Target namespace appers when you define an element for instance. The element name specifies the local name of the declared element, the namespace is determined from the target namespace.
When you refer an element declaration on the other hand you are not using target namespace, you must specify a QName (qualified name) as the value of the element ref attribute and that depends on the namespace context and here the default namespace may be important. I said may because you can have for instance your schema written like
and you will also have a valid schema.
Best Regards,
George
Target namespace appers when you define an element for instance. The element name specifies the local name of the declared element, the namespace is determined from the target namespace.
When you refer an element declaration on the other hand you are not using target namespace, you must specify a QName (qualified name) as the value of the element ref attribute and that depends on the namespace context and here the default namespace may be important. I said may because you can have for instance your schema written like
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://www.example.net/test"
xmlns:t="http://www.example.net/test">
<xs:element name="data">
<xs:complexType>
<xs:sequence>
<xs:element ref="t:foo"/>
<xs:element ref="t:bar"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="foo" type="xs:NCName"/>
<xs:element name="bar" type="xs:NCName"/>
</xs:schema>
Best Regards,
George
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service