View stylesheet

XML schema http://www.eionet.europa.eu/schemas/ippc-wi/dir20081elvbat_schema.xsd
Output type XML
Description Public XML
XSL file dir20081elvbat_xml_public.xsl (Last modified: 19 Feb 2010 11:48 )
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<xsl:output method="xml" indent="yes"/>

	<!-- copy everything that has no other pattern defined -->
	<xsl:template match="*">
		<xsl:copy>
			<xsl:copy-of select="@*"/>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>

	<!-- clear confidential data -->
	<xsl:template match="*[starts-with(local-name(), 'q-3-3') and ../q-3-3-Confidential='Confidential']">
		<xsl:copy>
			<xsl:copy-of select="@*"/>
			<xsl:if test="name()='q-3-3-Confidential'">
				<xsl:apply-templates/>
			</xsl:if>
		</xsl:copy>
	</xsl:template>

	<!-- replace XML Schema -->
	<xsl:template match="/*">
		<xsl:copy>
			<xsl:copy-of select="@*[local-name()!='noNamespaceSchemaLocation']"/>
			<xsl:attribute name="xsi:noNamespaceSchemaLocation">
				<xsl:call-template name="replace-string">
					<xsl:with-param name="text" select="@xsi:noNamespaceSchemaLocation"/>
					<xsl:with-param name="replace" select="'_schema.xsd'"/>
					<xsl:with-param name="with" select="'_public_schema.xsd'"/>
				</xsl:call-template>
			</xsl:attribute>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	
	<!-- helper template for replace() function  (XSLT 1.0 does not have this function)-->
	<xsl:template name="replace-string">
		<xsl:param name="text"/>
		<xsl:param name="replace"/>
		<xsl:param name="with"/>
		<xsl:choose>
			<xsl:when test="contains($text,$replace)">
				<xsl:value-of select="substring-before($text,$replace)"/>
				<xsl:value-of select="$with"/>
				<xsl:call-template name="replace-string">
					<xsl:with-param name="text" select="substring-after($text,$replace)"/>
					<xsl:with-param name="replace" select="$replace"/>
					<xsl:with-param name="with" select="$with"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$text"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>