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

RE: Select issue with some attr and others not.

Subject: RE: Select issue with some attr and others not.
From: "John Hamman" <John@xxxxxxxxxxxxxxxxx>
Date: Fri, 16 Apr 2004 13:32:20 -0400
xsl select
Ok a slightly larger challenge.
I have an xml file that list xml docs in it.
I want to merge the xml docs to produce the earlier results.

How do I combine what you have shown me with the below to make it work. I
have not been successful.

My filelist doc.
<?xml version="1.0"?>
<files>
	<pagefile>home.xml</pagefile>
	<listfiles>lista.xml</listfiles>
	<listfiles>listb.xml</listfiles>
</files>

My merge.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" encoding="iso-8859-1" indent="yes"/>
	<xsl:param name="required-lang" select="es-ES"/>
	<xsl:template match="/">
		<iThink.ePulp>
			<xsl:for-each select="files/listfiles">
				<xsl:variable name="file"
select="document(text())"/>
				<xsl:copy-of
select="$file/iThink.ePulp/child::*"/>
			</xsl:for-each>
			<xsl:apply-templates/>
		</iThink.ePulp>
	</xsl:template>
	<xsl:template match="files">
		<here>
			<xsl:for-each select="files/listfiles">
				<xsl:variable name="file"
select="document(text())"/>
				<xsl:copy-of select="$file/*"/>
			</xsl:for-each>
		</here>
	</xsl:template>
	<xsl:template match="*[@lang='es-ES']">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="node()">
		<xsl:if test="not(@lang) or (@lang=$required-lang)">
			<xsl:copy>
				<xsl:copy-of select="@*"/>
				<xsl:apply-templates/>
			</xsl:copy>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>




-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx] 
Sent: Friday, April 16, 2004 1:02 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Select issue with some attr and others not.


>  Well what I would like to do is set a param and be able to use the param
to
>  deside what lang is brought back. 

ah in an ideal world you would just change my template

<xsl:template  match="*[@lang='es-ES']"/>


to say


<xsl:template  match="*[not(@lang=$required-lang)]"/>

and pass required-lang="the queens english"
into the processor.
that would work in xslt2 drafts but unfortunately they banned the use of
variables on match patterns in xslt1 so you can't do that.

So you have to modify the main template not just add another, so now you
only need one template:


<xsl:template match="node()">
<xsl:if test="not(@lang) or (@lang=$required-lang)">
<xsl:copy>
<xsl:copy-of select="@*/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:if>
</xsl:template>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.