[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Generating an XSD: namespace difficulty

Subject: Generating an XSD: namespace difficulty
From: Ben Drees <ben@xxxxxxxxxxxx>
Date: Thu, 24 Mar 2005 16:06:36 -0800
xsd namespace
Hi,

I would like to generate XSD files from XML files using XSL, but I'm
having problems with namespaces in the result documents.

I have an XSD file that defines a simple vocabulary for describing
domain models, call it domain-model.xsd.

I have several XML files conforming to domain-model.xsd that describe
particular domain models - things like movie-domain-model.xml,
music-domain-model.xml, and so on, for example.

I have an XSL file that mostly does the right thing. The problem is that
I can't generate namespace prefixes in the XSL that come out properly in
the XSD result document.

For example, one of my result XSDs looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.mycompany.com/movie#"
elementFormDefault="qualified" attributeFormDefault="unqualified">

<xs:element name="movie">
.
.
.
</xs:element>

<xs:simpleType name="id">
  <xs:restriction base="xs:string"/>
</xs:simpleType>

<xs:simpleType name="markup">
  <xs:restriction base="xs:string"/>
</xs:simpleType>

<xs:complexType name="notes">
  <xs:sequence>
    <xs:element name="id" type="id"/>
    <xs:element name="display-name" type="markup"/>
    .
    .
    .
  </xs:sequence>
</xs:complexType>

The targetNamespace attribute in the xs:schema element causes the
simpleTypes named "id" and "markup" to be created in the
"http://www.mycompany.com/movie#" namespace, right? So then when these
types are referred to by elements in the "notes" complexType below, they
need a namespace prefix like "mov" for
"http://www.mycompany.com/movie#".

I can't figure out how to get the declaration of such a prefix into the
xs:schema result element since both the prefix and the URI to which it
refers are unknown until runtime.

I've found some information on generating XSL from XSL, the
namespace-alias element, and the fact that namespace nodes are different
than attribute nodes, which have all been helpful. But I'm still not
quite sure if what I'm trying to do is possible.

-Ben

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.