<?xml version="1.0"?>
<!-- This stylesheet is the result of following the instructions in
     the "Mapping XML to XML-Getting Started" through "Deleting Links
     in Simple Files" topics of the documentation. In the "Deleting Links
     in Simple Files" topic, the links for books<->Catalog and book<->Book
     were deleted. -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml"/>
 <xsl:param name="sort" select="'title'"/>
	<xsl:template match="/">
		<Catalog>
			<Book>
				<xsl:variable name="nodes" select="/books/book"/>
				<xsl:choose>
					<xsl:when test="$sort = 'title'">
						<xsl:apply-templates select="$nodes">
							<xsl:sort select="title" data-type="text" order="ascending"/>
						</xsl:apply-templates>
					</xsl:when>
					<xsl:when test="$sort = 'subject'">
						<xsl:apply-templates select="$nodes">
							<xsl:sort select="subject" data-type="text" order="ascending"/>
						</xsl:apply-templates>
					</xsl:when>
				</xsl:choose>
			</Book>
		</Catalog>
	</xsl:template>


	<xsl:template match="book">
		<xsl:copy-of select="subject"/>
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2006. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="yes" name="books.xml" userelativepaths="yes" externalpreview="no" url="books.xml" htmlbaseurl="" outputurl="" processortype="saxon8" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator="" ><advancedProp name="sInitialMode" value=""/><advancedProp name="bXsltOneIsOkay" value="true"/><advancedProp name="bSchemaAware" value="true"/><advancedProp name="bXml11" value="false"/><advancedProp name="iValidation" value="0"/><advancedProp name="bExtensions" value="true"/><advancedProp name="iWhitespace" value="0"/><advancedProp name="sInitialTemplate" value=""/><advancedProp name="bTinyTree" value="true"/><advancedProp name="bWarnings" value="true"/><advancedProp name="bUseDTD" value="false"/></scenario></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="catalog.xml" destSchemaRoot="Catalog" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no" ><SourceSchema srcSchemaPath="books.xml" srcSchemaRoot="books" AssociatedInstance="" loaderFunction="document" loaderFunctionUsesURI="no"/></MapperInfo><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->