Re: [xsl] Simple XSL question

Subject: Re: [xsl] Simple XSL question
From: Manu KY <manu_kry@xxxxxxxxx>
Date: Tue, 09 Oct 2001 10:37:17 +0530
Hi Vikram,
why dont you extract only the ARRAYID nodes like this:

<xsl:template match="/*/firstnode/ARRAY1ID">
<xsl:template match="/*/firstnode/ARRAY2ID">

Manu
Hi All

I am populating two JS arrays.Earlier i was using two
separate xsl file and now iam trying to consolidate
both files into one.

The xml strings are
1)<firstnode><ARRAY1ID>01</ARRAY1ID></firstnode>
2)<firstnode><ARRAY2ID>02</ARRAY2ID></firstnode>

Iam getting arrays
Array1IDarray["01"]
Array2IDarray[]

Array1IDarray[]
Array2IDarray["02"]

The XSL is

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
<xsl:output method="text" />
<xsl:template match="firstnode">
        ARRAY1IDarray = [
        <xsl:apply-templates select="//ARRAY1IDARRAY"/>
        ]
        ARRAY2IDarray = [
        <xsl:apply-templates select="//ARRAY2IDARRAY"/>
        ]
</xsl:template>

<xsl:template match="ARRAY1IDARRAY">

    "<xsl:value-of select="ARRAY1ID"/>"<xsl:if
test="position()!=last()">,</xsl:if>

</xsl:template>


<xsl:template match="ARRAY2IDARRAY"> "<xsl:value-of select="ARRAY2ID"/>"<xsl:if test="position()!=last()">,</xsl:if> </xsl:template>

</xsl:stylesheet>

How to get only the relevant array by still keeping
the topmost node in both cases as <firstnode>(i dont
want the zero size arrays).

Any Ideas/Pointers will be very usefull.


Thanks In Advance


Vikram

--- cutlass <cutlass@xxxxxxxxxxx> wrote:
> i think using the substring-before() is what u want
> to use to crack this
>
> see this technique in action at;
>
> http://www.dpawson.co.uk/xsl/sect2/N1755.html
>
> cheers, jim fuller
>
> ----- Original Message -----
> From: "Casadome, Francisco Javier"
> <Francisco.Casadome@xxxxxxxxxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Tuesday, September 18, 2001 3:11 PM
> Subject: [xsl] Comma delimited parameters...
>
>
> > Hi all,
> >
> > I have an XSL receiving parameter that is a list
> of names separated by
> > commas, like this:
> > name1,name2,name3,name4,name5,name6,
> > (note that the last one also have a comma at the
> end)
> >
> > Then I have a XML file with nodes that may or may
> not have these names as
> > childs, like this:
> >
> > <myXML>
> > <node1>
> > <name1>XXX</name1>
> > <name3>CCC</name3>
> > </node1>
> > <node2/>
> > <node3>
> > <name3>AAA</name3>
> > <name6>QQQ</name6>
> > </node3>
> > </myXML>
> >
> > What I want to do is to create a TAB-separated
> file with all the names in
> > the parameter as the first line, like this:
> >
> > -----------------------------------
> > name1 name2 name3 name4 name5 name6
> > -----------------------------------
> > XXX CCC
> >
> > AAA QQQ
> > -----------------------------------
> >
> > This is the XSL I have right now:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> > <xsl:output method="text"
> omit-xml-declaration="yes" indent="no"/>
> > <xsl:param name="Fields"/>
> >
> > <xsl:key name="AllPossibleFields" match="Entry/*"
> use="name()"/>
> >
> > <xsl:template match="Entries">
> > <xsl:apply-templates select="Entry/*[count(. |
> > key('AllPossibleFields',name())[1]) = 1]"/>
> > <xsl:text>
</xsl:text>
> > <xsl:for-each select="Entry">
> > <xsl:for-each select="*">
> > <xsl:if
> > test="contains($Fields,concat(name(),','))">
> > <xsl:value-of
> > select="."/><xsl:text>      </xsl:text>
> > </xsl:if>
> > </xsl:for-each>
> > <xsl:text>
</xsl:text>
> > </xsl:for-each>
> > </xsl:template>
> >
> > <xsl:template match="*">
> > <xsl:if
> test="contains($Fields,concat(name(),','))">
> > <xsl:value-of
> > select="name()"/><xsl:text> </xsl:text>
> > </xsl:if>
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> > Here you can see that what I do is to check if the
> current node plus a
> comma
> > is in the parameter list using the contains()
> function. I do this because
> I
> > don't know how to split this string without using
> an embed VBScript.
> > Also, I don't get name2, name4 and name5 in the
> header row, because there
> > isn't any node with such childs.
> >
> > Any great ideas ?
> >
> > Thanks in advance,
> > Frank.
> >
> >  XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
> >
>
>
>  XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
>


__________________________________________________ Do You Yahoo!? NEW from Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1

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


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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



Current Thread