Why are no namespace attributes validated by schema.

W

wooks

I apologise if this has been asked before, it is a bit hard to search
for.

I have an xml schema which defines the elements in the namespace
"urn:dummy". The schema does not contain any attribute
definitions/declarations.

The instance XML however gets transformed at runtime with the result
that a label attribute is added to each element.

An example of my instance XML is below

<?xml version="1.0"?>
<ROOTSTUB xmlns="urn:dummy">
<a label="Name">login</a>
<b label="derivation">restriction</b>
<c label="XML Data Type">NCName</c>
<d label="Minimum Field Length">6</d>
</ROOTSTUB>

Post transformation, errors are being thrown up because the validating
XML schema has no attribute definitions.

My question is given that the label attributes are not in any
namespace why are they being validated by the XML schema?
 
M

Martin Honnen

wooks said:
I apologise if this has been asked before, it is a bit hard to search
for.

I have an xml schema which defines the elements in the namespace
"urn:dummy". The schema does not contain any attribute
definitions/declarations.

Well then the elements are not allowed to have attributes.
The instance XML however gets transformed at runtime with the result
that a label attribute is added to each element.

An example of my instance XML is below

<?xml version="1.0"?>
<ROOTSTUB xmlns="urn:dummy">
<a label="Name">login</a>
<b label="derivation">restriction</b>
<c label="XML Data Type">NCName</c>
<d label="Minimum Field Length">6</d>
</ROOTSTUB>

Post transformation, errors are being thrown up because the validating
XML schema has no attribute definitions.

My question is given that the label attributes are not in any
namespace why are they being validated by the XML schema?

Because the schema defines the elements, you would need to allow
elements if you want to add them.
 
R

Richard Tobin

wooks said:
Post transformation, errors are being thrown up because the validating
XML schema has no attribute definitions.

My question is given that the label attributes are not in any
namespace why are they being validated by the XML schema?

There are two issues: are the attributes themselves valid? and are the
elements that they are attached to valid? Even if you don't want to
validate the attributes themselves, you have to declare that the
elements are allowed to have such attributes.

You need to use an attribute wildcard, and specify lax validation, e.g.

<anyAttribute namespace="##local" processContents="lax"/>

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top