xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett McLaughlin <bmcla...@algx.net>
Subject Re: Fw: schema question
Date Wed, 15 Dec 1999 14:38:53 GMT

Steve-
 

>>>>>>>>>>>
     <?xml version="1.0" encoding="UTF-8"?>
     <!-- <!DOCTYPE schema SYSTEM "structures.dtd"> -->
     <!DOCTYPE schema PUBLIC "-//W3C/DTD XML Schema Version 1.0//EN"
                            
"http://www.w3.org/XML/Group/1999/09/23-xmlschema/struct
     ures/structures.dtd">
     <schema>
      
     <element name="MAIN">
             <archetype name="Main">
                     <element ref="OTHER"/>
                     <attribute name="xmlns"/>
             </archetype>
     </element>
      
     <archetype name="Other" content="empty"/>
      
     <element name="OTHER" type="Other"/>
      
     </schema>
>>>>>>>>>>

>>>>>>>>>> 
and this xml file:
 

     <?xml version="1.0" encoding="UTF-8"?>
      
     <MAIN xmlns="play2.xsd">
             <OTHER/>
     </MAIN>
>>>>>>>>>>>>>>
      

Sorry for the weird formatting - Steve, can you make sure to turn off
HTML mail?  Thanks.

For this XML:

<code>
<?xml version="1.0" encoding="UTF-8"?>

<MAIN xmlns="play2.xsd">
  <OTHER/>
</MAIN>
</code>

a correct XML Schema would be:
<code>
<?xml version="1.0"?>
<!DOCTYPE schema PUBLIC "-//W3C/DTD XML Schema Version 1.0//EN"
                       
"http://www.w3.org/XML/Group/1999/09/23-xmlschema/structures/structures.dtd">

<schema>
  <element name="MAIN">
    <archetype>
      <element ref="OTHER"/>
      <attribute name="xmlns" type="string"/>
    </archetype>
  </element>

  <element name="OTHER">
    <archetype content="empty">
    </archetype>
  </element>
</schema>
</code>

XML4J has some (stated) problems with archetype declarations not
ocurring before archetype references are made.  Your best bet would be
to always use an implicit archetype (which is not what you are doing
with the OTHER element).  Also, FYI, when you do that like:

<code>
<element name="MAIN">
  <archetype>
    <!-- Archetype definition -->
  </archetype>
</element>
</code>

You don't need to give the archetype an identifier (name attribute)
because you are going to refer to it be the name of the element, not the
name of the archetype.  It cleans up the document a lot when you keep
that in mind.

Let me know the exact command(s) you are running within XML4J and I'll
help further... also try the schema I provided, or just change yours to
implicitly define OTHER and see if that works.

-Brett

Mime
View raw message