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

Generating IDs and seperating elements

Subject: Generating IDs and seperating elements
From: Jinesh Varia <jineshresearch@xxxxxxxxx>
Date: Wed, 5 Feb 2003 17:20:36 -0800 (PST)
steve lawer
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


Current Thread

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.