Digital Rant
Digital Rant

Reputation: 99

Adding asp.net control tags to an XML schema file

I have an xsd that describes XHTML documents. However the application I'm working with may have some selected asp.net controls within to the markup at the point is validated. Therefore the validation fails.

An example control could be:

<smart:Address runat="server" />

I wanted to add a new element to the xsd file but when I specify:

<xs:element name="smart:Address">

I get validation errors as an element name must not have a colon in it.

Can anyone suggest how I might be able to extend the schema file to allow selected server controls?

Update To help things along the full xsd is available at: xhtml1-transistional.xsd

Upvotes: 0

Views: 368

Answers (2)

Michael Kay
Michael Kay

Reputation: 163418

You need to put the element declarations for the smart namespace in a separate schema document, whose targetNamespace attribute identifies the namespace. The name attribute of constructs like xs:element and xs:simpleType is always an unqualified (local) name, implicitly qualified by the targetNamespace (use elementFormDefault="qualified" to ensure this is true even for local element declarations). When you refer to an element declaration in one schema document from a component in a different schema document, then (a) you must have an xs:import declaration to indicate the dependency, and (b) you use a qualified name for the reference, in the form prefix:local, where prefix is bound to the corresponding namespace using an xmlns:prefix="uri" declaration, usually on the xs:schema element.

Upvotes: 0

Mat&#237;as Fidemraizer
Mat&#237;as Fidemraizer

Reputation: 64943

You're missing that "smart" is an XML namespace.

In other words: you need to declare "smart" namespace:

<xs:schema xmlns:smart="http://someurl" ......

Learn more here:

Upvotes: 2

Related Questions