Dan Lugg
Dan Lugg

Reputation: 20592

Mixing XML namespaces with XHTML

How would I go about writing an XML schema, where the elements would be permitted for use mixed with elements from another namespace?

Specifically, if I want to use some elements for templating in an XHTML document as such:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:tmp="http://www.example.com/~/template">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

    <div id="idName">

        <tmp:region name="regionName">

            <div class="className">

                <h1>
                    <tmp:data name="dataName1">
                        <tmp:format type="formatType">
                            <tmp:param name="paramName" value="paramValue" />
                            <tmp:param name="paramName" value="paramValue" />
                        </tmp:format>
                    </tmp:data>
                </h1>

                <div>
                    <tmp:data name="dataName2" />
                </div>

            </div>

        </tmp:region>

    </div>

</body>

</html>

I don't want anyone to write the schema, I'm in the midst of doing that (I think correctly) but as mentioned, how could ensure that elements from the tmp namespace can be used as shown in the example? What would I need to include or omit from the XSD, or elsewhere?

Upvotes: 0

Views: 590

Answers (1)

Istao
Istao

Reputation: 7585

If you want anything somewhere, you can use xs:any :

<xs:any processContent="skip" namespace="http://www.foo.com/hello/world"/>

... to allow any element from the provided namespace, for instance.

Upvotes: 1

Related Questions