OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] dtd mixed content

[ Lists Home | Date Index | Thread Index ]

Fernando Cubria wrote:
 > Hello:
 > ¿Is there a way to tell, in dtd syntax, that a "link" element can contain any 
combination of text and "b" elements or just one "img" element?
 > I have tried with
 > <!ELEMENT link  ((#PCDATA | b)* | img) >
 > but I get an error.
 > Thank you.
 > Fernando

You can do this using choice. You could do this in XML Schema (xs:choice):

<xs:element name="link">
  <xs:complexType mixed="true">
    <xs:choice>
     <xs:element ref="b"/>
     <xs:element ref="img"/>
    </xs:choice>
   </xs:complexType>
  </xs:element>
<xs:element name="b" type="xs:string"/>
<xs:element name="img"/>

Or this in RELAX NG (choice):

<element name="link">
  <choice>
   <ref name="b"/>
   <ref name="img"/>
  </choice>
</element>

<define name="b">
   <mixed>
    <element name="b"><text/></element>
   </mixed>
</define>

<define name="img">
   <element name="img"><empty/></element>
</define>

Or in RELAX NG's compact syntax (| is choice):

element link { b | img }
b = mixed {element b { text }}
img = element img { empty }


Mike


> 
> http://www.latinmail.com - La forma más cómoda de enviar y recibir tus e-mails
> 
> 
> ------------------------------------------------------------------------
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS