Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: two elements with the same name but different types

From: "Kevin L Cobb" <kevin.cobb@--------.--->
To: "andrew welch" <andrew.j.welch@-----.--->, <xmlschema-dev@--.--->
Date: 3/20/2006 3:26:00 AM
You can't define the 'meta' elment multiple times. You want to define it
once and then describe its variablilty internally. The hard part of this
is that you're trying to define the "content" attribute's data type
based on what is in the "name" attribute. I'm not sure you can define
things this way in a schema. You're basically saying:

	IF 		name attribute is 'fixed_1', 'fixed_2', or
'fixed_3'
	THEN 		content attribute can be variable
	ELSE IF 	name attribute is 'fixed_4'
	THEN 		content attribute is 'fixed_5'
	ELSE		content attribute is 'text/html; charset=utf-8'

Which precludes you from defining what is in the 'content' attribute
withought knowing what is in the name attribute first. I'd be surprised
if schema allowed this. 


-Kevin


-----Original Message-----
From: xmlschema-dev-request@w... [mailto:xmlschema-dev-request@w...]
On Behalf Of andrew welch
Sent: Monday, March 20, 2006 6:56 AM
To: xmlschema-dev@w...
Subject: two elements with the same name but different types


Hi,

I'm trying to model the following in a schema:

<head>
  <title>the title<title>
  <meta http-equiv="Content-Type" content="text/html; =
charset=utf-8"/>
  <meta name="fixed_1" content="variable"/>
  <meta name="fixed_2" content="variable"/>
  <meta name="fixed_3" content="variable"/>
  <meta name="fixed_4" content="fixed_5"/> </head>

Here the first <meta> has two fixed value attributes, then the following
three have fixed name attributes (which are all different fixed values)
but any content attributes.  The last meta contains two fixed value
attributes, like the first.

Is this possible to model with XML Schema?  Currently I have:

<xs:element name="head">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="title"/>	=09
				=09
      <xs:element name="meta">
        <xs:complexType>
          <xs:attribute name="http-equiv" type="xs:string"
fixed="Content-Type"/>
          <xs:attribute name="content" type="xs:string"
fixed="text/html; charset=utf-8"/>
        </xs:complexType>
      </xs:element>
				=09
      <xs:element name="meta">
        <xs:complexType>
	  <xs:attribute name="name" type="xs:string" fixed="fixed_1"/>
          <xs:attribute name="content" type="xs:string"/>
        </xs:complexType>
      </xs:element>
				=09
      <xs:element name="meta">
        <xs:complexType>
          <xs:attribute name="name" type="xs:string" =
fixed="fixed_2"/>
          <xs:attribute name="content" type="xs:string"/>
	</xs:complexType>
      </xs:element>

....
      <xs:element name="meta">
        <xs:complexType>
          <xs:attribute name="name" type="xs:string" =
fixed="fixed_4"/>
          <xs:attribute name="content" type="xs:string"
fixed="fixed_5"/>
	</xs:complexType>
      </xs:element>

I read that this is ok as long as the element definitions are local and
not global, but I still get the error:

"two elements with the same name <meta> but different types appear in
the content model"

The other problem is defining when "fixed_4" is the value for the name
attribute, "fixed_5" must be the value for the content attribute. 
Isn't this a co-occurrence constraint?  In which case it's not possible
to do this in XML Schema...?

I'm writing this schema within an <xsl:import-schema> element in XSLT
2.0, so it's not possible to use Relax NG here.  This is to validate the
output as it's being generated by the transform... the alternative is to
do the validation as a seperate step in the pipeline, which might be the
only option....

thanks
andrew



From andrew.j.welch@g... Mon Mar 20 13:33:43 2006
Received: from aji.w3.org ([133.27.228.225])
	by frink.w3.org with esmtp (Exim 4.50)
	


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent