[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

[Fwd: Re: Re: Using a variable in XSLT]

Subject: [Fwd: Re: Re: Using a variable in XSLT]
From: Tim Müller-Seydlitz <tms@xxxxxxxxxxxxxxxxxx>
Date: Thu, 04 Sep 2003 13:10:05 +0200
xsl template match xs documentation
Hi,
I am still needing your help.

I want to transform a xsd file that contains documentation in multiple languages. Source Example
	<xs:element name="account" type="Account">
		<xs:annotation>
			<xs:documentation xml:lang="en">This is the English general description
				<sys:one>That's the special purpose description for system 1</sys:one>
				<sys:two>That's the special purpose description for system 2</sys:two>
                      </xs:documentation>
			<xs:documentation xml:lang="de">Das ist die deutsche allgemeneine Beschreibung.
				<sys:one>Das ist die spezielle Beschreibung für System 1</sys:one>
				<sys:two>Das ist die spezielle Beschreibung für System 2</sys:two>			</xs:documentation>
		</xs:annotation>
	</xs:element>

I would like to be able to choose a language. Such that all documentation elements but those in the selected language are erased.
I also would like to be able to choose a sys. Such that only the selected sys is present in the output.


The result file should like this. <xs:element name="account" type="Account"> <xs:annotation> <xs:documentation xml:lang="de"> Das ist die spezielle Beschreibung für System 1 </xs:documentation> </xs:annotation> </xs:element>

Currently my stylesheet that only gets part of the result looks like this.

Thanks in advance
TMS

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:sys="http://www.you-know-who.com/2003/systems"
version="1.0">

<xsl:param name="SystemSelected" select="'sys:ARTS'" />
<xsl:param name="lang" select="'de'" />

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

<xsl:template match='/'>
	<xsl:apply-templates/>
</xsl:template>

<!-- This is to take out the documentation in all but the selected language -->
<!-- Would be nice to use a variable here -->
<xsl:template match="//xs:annotation/xs:documentation[not(lang('de'))]" priority="2"/>
<!-- This is to select the SelectedLanguage and the SelectedSystem and to take it one level higher -->

<!-- This doesn't deliver the expected result. In particular because xs:documentation is not present in the output anymore -->
<xsl:template match="//xs:annotation/xs:documentation">
<xsl:apply-templates select="self::*[lang($lang)]/*[name()=$SystemSelected]"/>
</xsl:template>


<xsl:template match='@* | node()' priority="-1"> <xsl:copy> <xsl:apply-templates select='@* | node()'/> </xsl:copy> </xsl:template>

</xsl:stylesheet>





Regards







XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.