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

RE: searching the xml

Subject: RE: searching the xml
From: Rene de Vries <RdVries@xxxxxxxxxxx>
Date: Wed, 13 Jun 2001 16:26:21 +0200
wing msn free download
Earl,

This XSL works, but if it is a perfect one.....

<?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" indent="yes"/>
	
	<xsl:variable name="searchList" select="'scot john'"/>

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

	<xsl:template match="ROOT">
		<ROOT>
		<xsl:for-each select="employee">
		
			<xsl:variable name="found">
				<xsl:for-each select="emp">
					<xsl:if test="contains($searchList, text())">
					1
					</xsl:if>
				</xsl:for-each>
			</xsl:variable>
			
			<xsl:if test="$found=1">
				<employee group="{@group}">
					<xsl:copy-of select="wing"/>
					<xsl:for-each select="emp">
						<xsl:if test="contains($searchList, text())">
							<xsl:copy-of select="."/>
						</xsl:if>
					</xsl:for-each>
				</employee>
			</xsl:if>

		</xsl:for-each>
		</ROOT>
	</xsl:template>

</xsl:stylesheet>





Greetings Rene
   { @   @ }
        ^
      \__/

"You don't need eyes to see, you need vision!"

-----Oorspronkelijk bericht-----
Van:	Earl Spencer [SMTP:eapencer74@xxxxxxxxxxx]
Verzonden:	woensdag 13 juni 2001 10:52
Aan:	xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Onderwerp:	RE:  searching the xml

Hi Ben,
            This is where it gets tricky i think i was able to achieve this 
but i had a problem which even your stylesheet gives we need only that <emp> 
element which is required the other one should be omited
means for a string "scott,john," the result should  be

<ROOT>
<employee group="1">
   <wing>Management</wing>
   <emp>john</emp>
</employee>
<employee group="3">
   <wing>Production</wing>
   <emp>scot</emp>
  </employee>
</ROOT>







>From: "Ben Robb" <b.robb@xxxxxxxxxx>
>Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
>Subject: RE:  searching the xml
>Date: Tue, 12 Jun 2001 16:58:16 +0100
>
>Its going to make your life easier if you have an input string:
>"scott,john," (i.e. ending on a comma).
>
>This should do the job fairly efficiently.
>
>=================================
><?xml version="1.0" ?>
><xsl:stylesheet version="1.0" xmlns:xsl="http://,,,">
>
><xsl:parameter name="searchList"/>
>
><xsl:template match="/">
>	<xsl:apply-templates />
></xsl:template>
>
><xsl:template match="ROOT">
>	<ROOT><xsl:apply-templates /></ROOT>
></xsl:template>
>
><xsl:template match="employee">
>	<xsl:if test="contains($searchList, concat(emp/text(), ','))">
>		<employee group="{@group}">
>			<xsl:apply-templates/>
>		</employee>
>	</xsl:if>
></xsl:template>
>
><xsl:template match="wing">
>	<xsl:copy-of select="."/>
></xsl:template>
>
><xsl:template name="emp">
>	<xsl:if test="contains($searchList, concat(text(), ','))">
>		<xsl:copy-of select="."/>
>	</xsl:if>
></xsl:template>
>
></xsl:stylesheet>
>
>=================================
>
>Hmmm. There is probably a more elegant way using xsl:copy-of, but I
>can't think of it offhand...
>
>[I haven't even checked this as being wellformed, but it should work]
>
>Rgs,
>
>Ben
>
>
> > -----Original Message-----
> > From: Earl Spencer [mailto:eapencer74@xxxxxxxxxxx]
> > Sent: 12 June 2001 16:44
> > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  searching the xml
> >
> >
> > Hi folks,
> >           I have a search problem
> >
> > xml
> > ---
> > <ROOT>
> > <employee group="1">
> > <wing>Management</wing>
> > <emp>john</emp>
> > <emp>arnold</emp>
> > </employee>
> > <employee group="2">
> > <wing>Marketing</wing>
> > <emp>kathy</emp>
> > <emp>robert</emp>
> > </employee>
> > <employee group="3">
> > <wing>Production</wing>
> > <emp>jones</emp>
> > <emp>scot</emp>
> > </employee>
> > </ROOT>
> >
> > and now my problem is if i pass a stylesheet parameter like this
> > scott,john
> >
> > then my resulting xml file should be
> > <ROOT>
> > <employee group="1">
> > <wing>Management</wing>
> > <emp>john</emp>
> > </employee>
> > <employee group="3">
> > <wing>Production</wing>
> > <emp>scot</emp>
> > </employee>
> > </ROOT>
> >
> > can anybody suggest me the best way to do this......
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at http://explorer.msn.com
> >
> >
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> >
> >
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


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


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


Current Thread
  • searching the xml
    • Earl Spencer - Tue, 12 Jun 2001 11:42:07 -0400 (EDT)
      • <Possible follow-ups>
      • Ben Robb - Tue, 12 Jun 2001 12:01:14 -0400 (EDT)
      • Earl Spencer - Tue, 12 Jun 2001 12:43:55 -0400 (EDT)
      • Rene de Vries - Wed, 13 Jun 2001 10:19:40 -0400 (EDT) <=

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.