OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: RE: [docbook-apps] Creating correct HTML links from IDs


Just FYI it is fortunately fixed ;-)

I use nested for-ech loop to get back the original context

<xsl:for-each select="exsl:node-set($levels)/root/item">
   <xsl:variable name="linkend" select="@linkend"/>
   <xsl:variable name="label" select="@label"/>

   <!-- I cannot call simple.xlink here as I am out of context -->

   <xsl:for-each select="exsl:node-set($fragment)/section[1]">

	<!-- here I am 'back' so I can again access IDs database-->

      <xsl:call-template name="simple.xlink">
         <xsl:with-param name="linkend">
             <xsl:value-of select="$linkend"/>
         </xsl:with-param>
         <xsl:with-param name="label">
             <xsl:value-of select="$label"/>
         </xsl:with-param>      
      </xsl:call-template>
   </xsl:for-each>
   ...
</xsl:for-each>

Sorry for this noise...

Jan

> -----Original Message-----
> From: honyk [mailto:j.tosovsky@email.cz]
> Sent: Thursday, May 06, 2010 7:39 PM
> To: 'Bob Stayton'; 'DocBook Apps'
> Subject: RE: [docbook-apps] Creating correct HTML links from IDs
> 
> Hello,
> 
> I think I've located my problem, but I'm not sure how to fix it. All
> this
> topic seems to be now a bit OT here in DocBook list...
> 
> I have a link structure in the variable called 'levels':
>     <xsl:variable name="levels">
>         <root>
>             <item linkend="level_02" label="Level 2"/>
>             <item linkend="level_01" label="Level 1"/>
>         </root>
>     </xsl:variable>
> 
> It is unique for every title and generated automatically when
> processing
> matches 'title' template. Then each item is iterated to get the right
> URL to
> that linked ID. This iteration is problem as I am switching to a
> different
> context in which the 'key' function cannot access original IDs
> 'database'.
> 
> I've tried to find any forkaround, but still without success.
> 
> Before iteration I store the corresponding document fragment in a new
> variable:
> <xsl:variable name="fragment"
> select="//section[processing-instruction('navigation')]"/>
> 
> In this stage I am still able to access key database:
> <xsl:copy-of select="key('id', 'level_02')"/>
> 
> and I have no problem to generate the correct link:
>     <xsl:call-template name="simple.xlink">
>         <xsl:with-param name="linkend">
>             <xsl:value-of select="'level_02'"/>
>         </xsl:with-param>
>         <xsl:with-param name="label">
>             <xsl:value-of select="'Level 2'"/>
>         </xsl:with-param>
>     </xsl:call-template>
> 
> But this scenario is broken when 'for-each' construct is used:
>     <xsl:for-each select="exsl:node-set($levels)/root/item">
>         <xsl:sort select="position()" data-type="number"
> order="descending"/>
> 
> If the same look-up as above is performed now:
> <xsl:copy-of select="key('id', $linkend)"/>
> nothing is returned.
> 
> I've tried to specify 'node' parameter in simple.xlink template:
>         <xsl:variable name="linkend" select="@linkend"/>
>         <xsl:call-template name="simple.xlink">
>             <xsl:with-param name="node"
> select="exsl:node-set($fragment)//*[@id = $linkend]"/>
>             <xsl:with-param name="linkend">
>                 <xsl:value-of select="@linkend"/>
>             </xsl:with-param>
>             <xsl:with-param name="label">
>                 <xsl:value-of select="@label"/>
>             </xsl:with-param>
>         </xsl:call-template>
> 
> but this doesn't help.
> 
> So there is problem of loosing the access to keys when original context
> is
> changed. I think this is rather a fundamental XSLT thing then DocBook
> itself, but if there is any tip, I would be grateful for it.
> 
> I need both - iterating and an access to keys... Up to now I've though
> keys
> are accessible from everywhere...
> 
> Regards,
> Jan
> 
> 
> > -----Original Message-----
> > From: Bob Stayton [mailto:bobs@sagehill.net]
> > Sent: Thursday, May 06, 2010 2:33 AM
> > To: honyk; DocBook Apps
> > Subject: Re: [docbook-apps] Creating correct HTML links from IDs
> >
> > That should work.  The error message is coming from the template
> named
> > 'check.id.unique', and it indicates that the id value is not found in
> > the xsl:key with
> > name="id".  That xsl:key in an index of the all the id values in the
> > current document,
> > and it is loaded before the document is processed with formatting
> > templates.  If the
> > id value is on an element in the document, it should be in that
> > xsl:key.  From the
> > information you provided, I can't tell why that isn't the case.
> >
> > Bob Stayton
> > Sagehill Enterprises
> > bobs@sagehill.net
> >
> >
> > ----- Original Message -----
> > From: "honyk" <j.tosovsky@email.cz>
> > To: <docbook-apps@lists.oasis-open.org>
> > Sent: Tuesday, May 04, 2010 9:29 AM
> > Subject: [docbook-apps] Creating correct HTML links from IDs
> >
> >
> > > Hello Everyone,
> > >
> > > in my customization layer for chunked HTML output I need to create
> > several
> > > "navigation" links. I can retrieve set of documents IDs together
> with
> > their
> > > titles, but I don't know what is the best way to generate HTML
> links
> > from
> > > this data. In PDF I can use IDs directly, but for chunked output I
> > need also
> > > to determine the final HTML page file name...
> > >
> > > I've tried simple.xlink template:
> > > <xsl:call-template name="simple.xlink">
> > >  <xsl:with-param name="linkend" select="'myID'"/>
> > >  <xsl:with-param name="content" select="'myLink'"/>
> > > </xsl:call-template>
> > >
> > > what generates <a> element with the appropriate content, but the
> href
> > > element is empty. In the log I see the following:
> > > Error: no ID for constraint linkend: myID.
> > > (that ID is present there)
> > >
> > > Can I fix this somehow? Is there better template for this in
> DocBook
> > > distribution or should I write something by myself?
> > >
> > > Thanks for any tips.
> > >
> > > Regards,
> > > Jan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]