473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

[XSL] generating links to chapter, header, subheaders with autonumeration

Witam,
mam nastepujacy problem:
XSLT 2.0,

Hi,
i've got following problem with xslt 2:

my xml doc looks something linke:

<manual>
<chapter id="intro-some" title="some title23l>
<header id="intro-some-header" title="some titleser3 2">
<part id="jakisid12" title="jakistitle2435">
...
</part>
<part id="jakisid3343" title="jakistitle2345">
...
</part>
</header>
</chapter>

jest dowolna liczba headerow i chapterow, part jest opcjonalny.

there are chapters (non-optional), headers (in chapters) (non-
optional) and parts (in chapters) (optional)

When i'm transforming to html when i create snippet about header,
chapter or part im presenting something like:
"1. title of chapter one" (for chapters), "1.2. title of header
two" (for header two in chapter one), "1.2.4 title of part four" (for
part number four in header number two in chapter number one"

Im using following code (i.e. for part numeration):

<xsl:number level="multiple" count="chapter|header|part"
format="1.1.1 " />

And xml is auto numbering my chapters, headers and parts.

With anything that I wrote for now there are no problems. But i have
new requirement for my xsl transformation.

In my xml inside chapter or header or part i can insert element:
<linkLeech href="jakisIDdoChapterLubHeaderLubPart"/>
which should be replaces (in target document i.e. html) to:
<a href="xxx">1.2.3 title of target part</a(if href is referring
part by id)
or
<a href="xxx">1.2 title of target header </a(if href is referring
header by id)
or
<a href="xxx">1. title of target chapter</a(if href is referring
chapter by id)

And i have a problem: I can read the title of target element(chapter,
header, part) but I can not determine which number should I insert
before title ot target element. At this time I can not determine the
position of target element reffered to other elements (in context-
node)

I hope my description was clear ehough, i will by pleased if someone
with bigger experience than me could help me with this problem, thanks
for all kind of help.

Mar 5 '07 #1
3 1850
On Mar 5, 2:54 pm, jszczepankiew...@gmail.com wrote:
Witam,
mam nastepujacy problem:
XSLT 2.0,
This is an English-speaking newsgroup. There's absolutely
no need to intersperse Polish (or whichever language that
is) with English.
my xml doc looks something linke:
No it doesn't. It's not well-formed. Posting sloppy
examples is largely equivalent to shouting: "I don't want
your help!"
<manual>
<chapter id="intro-some" title="some title23l>
<header id="intro-some-header"
title="some titleser3 2">
<part id="jakisid12" title="jakistitle2435">
...
</part>
<part id="jakisid3343"
title="jakistitle2345">
...
</part>
</header>
</chapter>

When i'm transforming to html when i create snippet about
header, chapter or part im presenting something like:
"1. title of chapter one" (for chapters), "1.2. title of
header two" (for header two in chapter one), "1.2.4 title
of part four" (for part number four in header number two
in chapter number one"
[xsl:number problems]

Here's a little something for you to chew on:

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:usr="http://example.org/usr">
<xsl:function name="usr:num">
<xsl:param name="elt"/>
<xsl:choose>
<xsl:when test="not($elt/parent::*)"/>
<xsl:when
test="$elt[self::chapter|self::header|self::part]">
<xsl:value-of select="usr:num($elt/parent::*)"/>
<xsl:value-of
select=
"
count
(
$elt/preceding-sibling::chapter|
$elt/preceding-sibling::header|
$elt/preceding-sibling::part
)+1
"/>
<xsl:text>.</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="usr:num($elt/parent::*)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="usr:tag">
<xsl:param name="elt"/>
<xsl:value-of select="usr:num($elt)"/>
<xsl:text</xsl:text>
<xsl:value-of select="$elt/@title"/>
</xsl:function>
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*"/>
<xsl:template match="chapter|header|part">
<xsl:value-of select="usr:tag(.)"/>
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
</xsl:stylesheet>

--
Pavel Lepin

Mar 5 '07 #2
first I want to apologise for inclusion of my mother language, I was
posting it to second group and was in hurry and do not deleted ...
nevermind.
Someone helped me and it was so simple, take a look:
<xsl:template match="linkLeech">
<xsl:for-each select="//*[@id=current()/@href]">
<xsl:number level="multiple" count="chapter|header|part"
format="1.1.1" />
....

Thanks for all help, i will take a look at your suggestions.

Mar 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Nagi Peters | last post by:
Hello I try to tranform a XML Document in php/Sablotron with the following XSL Stylesheet. I tried to write "@id='1'" with the variable chapter_id. So it works: <xsl:variable...
2
by: Waqas Ashraf | last post by:
hi, I am a newbie at xml/xsl. I m trying to generate a book of papers marked up in xml. I have a simple xml file which includes the papers, and i have xsl stylesheet document which generates the...
3
by: Prabh | last post by:
Hello all, I want to HTML-ize an .xml (Test.xml) file and am running into a problem with my XSL file. The .xml contains info about each tag, called 'targets' and each target has a message with...
0
by: Rary | last post by:
I am using XSL:FO to generate PDF report for my XML, generating it in tables, i want that tables should completely be at one place, if there is a page break , all the contents of the table should...
4
by: JLP | last post by:
Hello, I have a couple of hundred books in TEI based XML. I want to output html and pdf documents. I started building my own style sheets to do this and I ran into a problem with footnotes. Many...
0
by: Nathan | last post by:
Hi, I seem to having a peculiar problem with the display of odd and even pages in XSL-FO. Here is a small background of the problem. My xsl stylesheet mentions my fo:layout-master-set as ...
0
by: Matthias | last post by:
Hi all, I have a problem with XSL FO. I wrote a handbook for my application in XML and formats it with xsl:fo (FOP) for PDF output. The handbook has some chapters. I have to write the actual...
15
by: lucky | last post by:
Hi Guys You are probably my last chance to avoid getting crazy To help you understand my problem I have put images online showing the issue I have: http://www.australix.net/images/pb I...
6
by: Ohlenroth | last post by:
hello, I am new to Bytes and I am not sure if this is the right plattform. but I found several posts regarding XSL. (If this is not the rigth forum, I apologize. Could you point me to another one...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.