Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Conditional Levels of a Schema

From: Dieter Menne <dieter.menne@------------.-->
To: xmlschema-dev@--.---
Date: 4/6/2009 12:41:00 AM


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.


From cmsmcq@b... Tue Apr 07 04:08:48 2009
Received: from bart.w3.org ([128.30.52.63])
	by fr


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