W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2009

Re: Conditional Levels of a Schema

From: Dieter Menne <dieter.menne@menne-biomed.de>
Date: Mon, 6 Apr 2009 07:40:40 -0700 (PDT)
Message-ID: <22910104.post@talk.nabble.com>
To: xmlschema-dev@w3.org

Pete Cordell-5 wrote:
> I don't know whether this is possible, but could you define an attribute
> in
> another namespace, such that you do:
> <xs:element name="patients" minOccurs="0" maxOccurs="1"
>                 hrm:context-specific="true"/>
> and then have a style sheet that says if @hrm:context-specific is present,
> modify the minOccurs and maxOccurs attributes appropriately for the mode
> you
> want?

Thanks to Pete and Michael. The Stylesheet->Schema way seemed to be the
easiest for me. A minor problem now is that I would like to parameterize the
parameters, so that the two alternatives below could be selected with one
external parameter, e.g. anonymous = "true" (there are much more in the
final). Somehow, I failed getting the syntax right.

Apologies again for the multi-posting, looks like nabble had not updated the
forum all the time, now I see the mess I left.


<?xml version="1.0"?>
<!-- Following Michael Kay's suggestion on 
     this stylesheet generated different flavors of the XHRM Schmema, e.g
     use in research or for in-hospital use.
		 Alternatively, parameters could be passed upon transformation.
<xsl:stylesheet version="1.0"
  <!-- For In-Hospital use: patient name required -->
  <xsl:param name="minPatients">1</xsl:param>
  <xsl:param name="maxPatients">1</xsl:param>

  <!-- For research: patient name must not be included -->
	<xsl:param name="minPatients">0</xsl:param>
  <xsl:param name="maxPatients">0</xsl:param>
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="/">
		<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="0.3" >
			<xs:element name="xhrm">
						<xs:element name="device" type="xs:string"/>
						<xs:element minOccurs="{$minPatients}" maxOccurs="{$maxPatients}"
						            name="patient" type="xs:string"/>

View this message in context: http://www.nabble.com/Conditional-Levels-of-a-Schema-tp22905179p22910104.html
Sent from the w3.org - xmlschema-dev mailing list archive at Nabble.com.
Received on Monday, 6 April 2009 14:41:17 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:16 UTC