Re: Conditional Levels of a Schema

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.

Dieter


<?xml version="1.0"?>
<!-- Following Michael Kay's suggestion on 
     http://www.nabble.com/Conditional-Levels-of-a-Schema-td22905179.html 
     this stylesheet generated different flavors of the XHRM Schmema, e.g
for
     use in research or for in-hospital use.
		 Alternatively, parameters could be passed upon transformation.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!-- 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:complexType>
					<xs:sequence>
						<xs:element name="device" type="xs:string"/>
						<xs:element minOccurs="{$minPatients}" maxOccurs="{$maxPatients}"
						            name="patient" type="xs:string"/>
					</xs:sequence>
				</xs:complexType>
			</xs:element>
		</xs:schema>
	</xsl:template>
</xsl:stylesheet>

-- 
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