|
Subject: Re: [xsl] Generating IDs and seperating elements From: Jinesh Varia <jineshresearch@xxxxxxxxx> Date: Wed, 5 Feb 2003 19:53:49 -0800 (PST) |
Hello charles
I am sorry there was a typo there.
I forgot to declare the paramenters. thanks for ###2
but with ###3 even if there is call-template
mentioned.. it works fine for one.(generates ids) but
I want to use the same id that has been generated at
other place where there is tempperid. what should I
type over there so that the same id that I am
generating can be used at ####2
###1 still not known :(
just to give you an overview, I am trying to seperate
authors from the publication data. so that I can
import it in the database as a publication table and
persons table.
Jinesh
--- Charles White <chuck@xxxxxxxxxxx> wrote:
> Hi Jinesh:
>
> You have a couple things going on here with the
> structure of your XSLT.
> First, you didn't declare your parameters anywhere,
> at least not in the code
> you provided here.
>
> So, in answer to ######2, the first part of your
> author template should
> look like this:
> <xsl:template match="author">
> <xsl:param name="temppubid" />
> <xsl:param name="tempperid">
> <xsl:call-template name="generate-author-id"/>
>
> It seems you were trying to call the template named
> generate-author-id,
> which is defined elsewhere, but you used the
> xsl:template element to attempt
> to do so, so I changed this:
> <xsl:template name="generate-author-id">
> to this
> <xsl:call-template name="generate-author-id"/>
> in the code above (but not in the originally defined
> template named
> generate-author-id that you built later in the
> stylesheet).
>
> #####3: You took a sort of object-oriented
> developer's approach to
> concatenation and mistakenly used the plus (+)
> operator in the concat
> function, where as you should use commas instead:
>
> concat('800000000',$last+$this)
>
> becomes
>
> select="concat('800000000',$last, $this)"
>
> I'm not sure what you are asking about with ####1,
> so I'll let someone else
> take over there. :-)
>
> Cheers,
>
> Chuck White
> Author, Mastering XSLT, Sybex Books
> http://www.javertising.com/webtech
> http://www.tumeric.net
> ----- Original Message -----
> From: "Jinesh Varia" <jineshresearch@xxxxxxxxx>
> To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Wednesday, February 05, 2003 5:20 PM
> Subject: [xsl] Generating IDs and seperating
> elements
>
>
> > Hello people,
> > two unique problems:
> >
> > My XML is
> > <publication pubid="0002">
> > <author>steve lawer</author>
> > ........
> > <publication>
> >
> >
> > I want my new XML as:
> > <publication pubid="0002">
> > ........
> > </publication>
> > <person perid="100000004"> <!-- new id generation
> -->
> > <personname>steve lawer</personname>
> > </person>
> > <pubper> <!-- publication-person intersection -->
> > <pubid>0002</pubid>
> > <perid>100000004</perid>
> > </pubper>
> >
> > My XSL is:
> > <?xml version="1.0"?>
> >
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > <xsl:output method="xml" indent="yes"/>
> >
> > <xsl:template match="publication">
> >
> > <publication>
> > <xsl:copy-of select="@*|*[not(self::author or
> > self::editor)]"/> <!-- this is just to cut the
> authors
> > element-->
> > </publication>
> >
> > <xsl:if
> test="author=not(.=preceding::author|editor)"
> > ><!-- this is so that we get unique authors and
> > editors: Please comment on this #####1-->
> > <xsl:apply-templates select="author">
> > <xsl:with-param name="temppubid" select="@pubid"
> />
> > </xsl:apply-templates>
> > </xsl:if>
> > </xsl:template>
> >
> > <xsl:template match="author">
> > <person>
> > <xsl:attribute name="perid">
> > <xsl:template name="generate-author-id"> <!--
> > generating ids -->
> > </xsl:attribute>
> > <personname>
> > <xsl:value-of select="."/>
> > </personname>
> > </person>
> > <pubper>
> > <pubid>
> > <xsl:value-of select="$temppubid"/><!-- Why
> is
> > this not printing the parameter that I am sending
> > #####2 -->
> > </pubid>
> > <perid>
> > <xsl:value-of select="$tempperid"/> <!- I
> > want to print the id that I just created for
> person
> > over here. Why is this not printing....how to
> print
> > the value ####3-->
> > </perid>
> > <persontype>1</persontype>
> > </pubper>
> > </xsl:template>
> >
> >
> >
> > <xsl:template name="generate-author-id">
> > <xsl:variable name="last"
> >
>
select="number(preceding::author[@perid][1]/@perid)"/>
> > <xsl:variable name="this"
> > select="count(preceding::author[not(@perid)])+1"/>
> > <xsl:variable name="temp"
> > select="concat('800000000',$last+$this)" />
> > <xsl:value-of
> > select="substring($temp,string-length($temp)-9)"
> />
> > <!-- we just want 10-digit IDs -->
> > <xsl:template>
> >
> > </xsl:stylesheet>
> >
> >
> >
> >
> > Please comment on ###1, ###2, ###3
> > I dont know why is this not working...any help
> will be
> > appreciated
> >
> > Thanks in advance
> > jinx
> >
> > =====
> >
>
-----------------------------------------------------------------
> > Jinesh Varia
> > Graduate Student, Information Systems
> > Pennsylvania State University
> > Email: jinesh@xxxxxxx
> >
>
-----------------------------------------------------------------
> > 'Self is the author of its actions.'
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> > http://mailplus.yahoo.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
>
=====
-----------------------------------------------------------------
Jinesh Varia
Graduate Student, Information Systems
Pennsylvania State University
Email: jinesh@xxxxxxx
-----------------------------------------------------------------
'Self is the author of its actions.'
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Generating IDs and sepera, Charles White | Thread | Re: [xsl] Generating IDs and sepera, Charles White |
| Re: [xsl] Generating IDs and sepera, Charles White | Date | [xsl] generating id by calling temp, Jinesh Varia |
| Month |