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]
Other format: [Raw text]

does an element have a unique id?, and a problem to solve


hi all members,

I'm trying do the following:
1) have an XML file with e.g. 4 <content/>
2) call the page - if page doesn't have a parameter, XSLT shows the first
<content/> with some formating and the following 3 with a simple formating
3) if the page has a parameter than it renders <content/> that has the id,
and format the 3 others with the simple style.

What the problem is:
1) how to specifiy parameter in XSLT in Cocoon so that it works also when no
parameter is given; I've added:

  <map:match pattern="*/*-*">
    <map:generate src="content/{1}/{2}.xml"/>
    <map:transform src="transforms/inners.xsl">
        <map:parameter name="param" value="{3}"/>
        <map:parameter name="css-stylesheet" value="default.css"/>
    </map:transform>
    <map:serialize type="html"/>
  </map:match>

so,  it works when there is a "*/*-1" but comes to an error when typing
"*/*", however I would like to declare in XSL that if there is no param
("-*"), use the first <content/>. I don't know how to make it work this way.
(???)

2) I've tried to use the postion() for specifing the parameter to render
with the special formating as follows:

    <xsl:for-each select = "content[position() != $firstcontent]">
     <xsl:if test = "position() mod 2 = 0">
     <p/><h3><xsl:value-of select="header1"/></h3>
     <xsl:value-of select="concat(substring-before(para, '.'),
'.')"/>&#160;<a href="{position()}" class="navigators">&#x00BB;</a>
      </xsl:if>
 </xsl:for-each>

but in case of $firstcontent=2 the for-each will not list it, and position
will start from 1, so position() doesn't show the original listed
id/position as it is in the XML doc. Beyond adding an attribute to the
element in the XML for specifing a unique identifier, is there something
else how I can find out the original XML content position number?

What's make it hard, so that a simple for-each for only "content" won't
work, is that I have 2 columns, and if I use only the content for-each list
and display every odd and even position(), than incase of a $firstcontent=2
and having 5 <content/> the first column will have pos:1,3,5 and the second
column will have pos: 4, but what I'd like to show is that every second
<content/> goes to the same column => column1 will have: pos:1, 4 and
column2 will have pos: 3,5.


If anyone understands my situation, and can help me, thanks in advance for
writing me an e-mail.

Regards,

Thomas





 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]