xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Buroff" <...@lucent.com>
Subject Re: Fw: schema question
Date Wed, 15 Dec 1999 16:18:36 GMT

  ----- Original Message ----- 
  From: Brett McLaughlin 
  To: general@xml.apache.org 
  Sent: Wednesday, December 15, 1999 9:38 AM
  Subject: Re: Fw: schema question



  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>

The problem with this solution is that if I have 10 elements that should
all have the same format, I have to repeat the archetype 10 times.


  XML4J has some (stated) problems with archetype declarations not
  ocurring before archetype references are made.  Your best bet would be

But in my example, the archetype declaration does occur before it is used.

  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