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: Difference between "/" and "//"


Earl,

It wasn't clear that you didn't wanted it that way, but just combine the solution of Jeni Tennison and mine to:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:fo="http://www.w3.org/1999/XSL/Format";>
<xsl:output method="xml" indent="yes"/>

<xsl:variable name="searchList" select="'12,13,'"/>

<xsl:template match="ROOT">
	<xsl:element name="ROOT">
		<xsl:apply-templates select="MC"/>
	</xsl:element>
</xsl:template>

<xsl:template match="MC">

	<xsl:if test="SC[contains($searchList, concat(normalize-space(@BCID), ','))]">
		<xsl:element name="MC">
			<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>

			<xsl:apply-templates select="SC"/>
		</xsl:element>
	</xsl:if>

</xsl:template>

<xsl:template match="SC">
	<xsl:if test="contains($searchList, concat(normalize-space(@BCID), ','))">
		<xsl:copy-of select="."/>
	</xsl:if>
</xsl:template>

</xsl:stylesheet>

Greetings Rene
   { @   @ }
        ^
      \__/

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

-----Oorspronkelijk bericht-----
Van:	Earl Spencer [SMTP:eapencer74@hotmail.com]
Verzonden:	vrijdag 22 juni 2001 15:56
Aan:	xsl-list@lists.mulberrytech.com
Onderwerp:	RE: [xsl] Difference between "/" and "//"

hi Rene,

I get the result the same way u get it but that is what my problem is i 
think as i am new to the list and to xslt i am not able to convey my problem 
here properly.

here if searchList is '12,'
the result of this transformatioin would be

<ROOT>
	<MC id="1">
		<SC BCID="12"/>
	</MC>
</ROOT>

but if searchList is '12,13,'

the reslut would be

<ROOT>
	<MC id="1">
		<SC BCID="12"/>
	</MC>
        <MC id="1">
		<SC BCID="13"/>
	</MC>
</ROOT>

but i am looking for a result like this

<ROOT>
	<MC id="1">
		<SC BCID="12"/>
		<SC BCID="13"/>
	</MC>
</ROOT>

means i need to get the MC only once for each id is there a way to do this , 
any help would be greatefull

Thanks
SPENCER
>This could not be your XML, because it isn't well-formed at all. I think 
>you mean:
><ROOT>
>	<MC id="1">
>		<SC BCID="12"/>
>		<SC BCID="13"/>
>		<SC BCID="14"/>
>	</MC>
>	<MC id="2">
>		<SC BCID="15"/>
>		<SC BCID="16"/>
>		<SC BCID="17"/>
>	</MC>
>	<MC id="3">
>		<SC BCID="21"/>
>		<SC BCID="22"/>
>		<SC BCID="23"/>
>	</MC>
></ROOT>
>
>
>I would put test were it should be: in a SC-template. I tested it with 
>'12,' '13,' and '12,13,' and it works:
><xsl:stylesheet version="1.0" 
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
>xmlns:fo="http://www.w3.org/1999/XSL/Format";>
><xsl:output method="xml" indent="yes"/>
>
><xsl:variable name="searchList" select="'12,13,'"/>
>
><xsl:template match="ROOT">
>	<xsl:element name="ROOT">
>		<xsl:apply-templates/>
>	</xsl:element>
></xsl:template>
>
><xsl:template match="MC">
>	<xsl:apply-templates>
>		<xsl:with-param name="id" select="@id"/>
>	</xsl:apply-templates>
></xsl:template>
>
>
><xsl:template match="SC">
><xsl:param name="id"/>
>	<xsl:if test="contains($searchList, concat(normalize-space(@BCID), ','))">
>		<xsl:element name="MC">
>			<xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
>			<xsl:copy-of select="."/>
>	</xsl:element>
>	</xsl:if>
></xsl:template>
>
>
></xsl:stylesheet>
>
>Greetings Rene
>    { @   @ }
>         ^
>       \__/
>
>"You don't need eyes to see, you need vision!"
>
>-----Oorspronkelijk bericht-----
>Van:	Earl Spencer [SMTP:eapencer74@hotmail.com]
>Verzonden:	vrijdag 22 juni 2001 9:52
>Aan:	xsl-list@lists.mulberrytech.com
>Onderwerp:	RE: [xsl] Difference between "/" and "//"
>
>Hi Micheal,
>This is my xsl
><xsl:template match="MC">
>         <xsl:if test="contains($searchList,
>concat(normalize-space(SC/@BCID), ','))">
>                 <MC id="{@id}">
>                     <xsl:apply-templates/>
>                 </MC>
>         </xsl:if>
></xsl:template>
>
>
>and my xml goes like this
><ROOT>
><MC id="1">
><SC BCID="12">
><SC BCID="13">
><SC BCID="14">
><MC>
><MC id="2">
><SC BCID="15">
><SC BCID="16">
><SC BCID="17">
><MC>
><MC id="3">
><SC BCID="21">
><SC BCID="22">
><SC BCID="23">
><MC>
><ROOT>
>
>if i give a search string of 12,16,21,
>i have to get
>
><ROOT>
><MC id="1">
><SC BCID="12">
><MC>
><MC id="2">
><SC BCID="16">
><MC>
><MC id="3">
><SC BCID="21">
><MC>
><ROOT>
>which i get
>if my search string is 12,i get the desired result
>if my search stirng is 13, i get a blank xml with only the <ROOT>
>
>it means my search string is searching for only the first SC but when it is
>given as multiple elements i get the right answer.
>
>Any suggestion
>Thanks
>Spencer
>
>
>
>
> >From: "Michael Kay" <mhkay@iclway.co.uk>
> >Reply-To: xsl-list@lists.mulberrytech.com
> >To: <xsl-list@lists.mulberrytech.com>
> >Subject: RE: [xsl] Difference between "/" and "//"
> >Date: Thu, 21 Jun 2001 17:46:32 +0100
> >
> >No, I can't give you a clue. It would help if you wrote the question in
> >grammatical sentences, and it would help even more if you showed us what
> >your source XML and stylesheet look like.
> >
> >Mike Kay
> >Software AG
> >
> > > -----Original Message-----
> > > From: owner-xsl-list@lists.mulberrytech.com
> > > [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of
> > > Earl Spencer
> > > Sent: 21 June 2001 17:24
> > > To: XSL-List@lists.mulberrytech.com
> > > Subject: [xsl] Difference between "/" and "//"
> > >
> > >
> > > Hi ppl,
> > >            What is the actual difference between "/" and "//"
> > > cause i have a
> > > petty problem when use a stylesheet to search the xml then i
> > > get the correct
> > > result only if there is more than one string or else i get a
> > > wrong result if
> > > there is only one search element i pass the search elements this way
> > >
> > > "23,34,56,78," when this search string is sent i get the
> > > correct result
> > >
> > > "34," but this string results in a null can anybody give me a
> > > clue what went
> > > wrong.
> > >
> > > Thanks in advance
> > > Spencer
> > > _________________________________________________________________
> > > 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
>

_________________________________________________________________
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


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