This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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@cscape.com>
>Reply-To: xsl-list@lists.mulberrytech.com
>To: <xsl-list@lists.mulberrytech.com>
>Subject: RE: [xsl] 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@hotmail.com]
> > Sent: 12 June 2001 16:44
> > To: XSL-List@lists.mulberrytech.com
> > Subject: [xsl] 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]