473,606 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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="jakistit le2435">
...
</part>
<part id="jakisid3343 " title="jakistit le2345">
...
</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="jakisIDdo ChapterLubHeade rLubPart"/>
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 1860
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="jakistit le2435">
...
</part>
<part id="jakisid3343 "
title="jakistit le2345">
...
</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:styleshe et 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|s elf::header|sel f::part]">
<xsl:value-of select="usr:num ($elt/parent::*)"/>
<xsl:value-of
select=
"
count
(
$elt/preceding-sibling::chapte r|
$elt/preceding-sibling::header |
$elt/preceding-sibling::part
)+1
"/>
<xsl:text>.</xsl:text>
</xsl:when>
<xsl:otherwis e>
<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="linkLeec h">
<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
4120
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 name="chapter_id">1</xsl:variable> <xsl:template match="chapter"> snipp..
2
1957
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 output in the form of ONE xhtml page. I can generate the entire book as one xhtml file but I want to be able to generate each paper on a DIFFERENT page. how can i achieve that? My simple xml file looks as below: <book>
3
1659
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 certain priority. I want to bundle all these targets in a top-area which have "a href" links to the details section down below. Also, I want to ignore messages with 'debug' priority and print only the 'info' priority messages.
0
3941
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 move to the next page. can any one suggest a way out? This is my code (number 18, Brunelli Rocco, should move to the next page): XML: <?xml version="1.0" encoding="windows-1252"?>
4
1736
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 of my documents have longer footnotes so I did the following: <p>Text...text...text...<note><p>footnote body.</p><p>The next paragraph in the footnote</p></note></p>
0
2420
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 <fo:layout-master-set> <fo:simple-page-master margin-left="0.5in" margin-right="0.5in" page-width="8.5in" margin-bottom="0.5in" master-name="Section-odd-page" margin-top="0.5in" page-height="14in"> <fo:region-after region-name="xsl-region-after-odd"
0
1140
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 chapter heading (e.g. Handbook - Chapter 1 HEADING_OF_CHAPTER_ONE) into the header or footer to follow our styleguide. I use a template for the header like: <xsl:template name="Header"> <fo:table table-layout="fixed">
15
2085
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 have an XML file containing links and I use an XSL file to build a
6
3908
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 then please.) I have an xsl stylesheet which reads an xml input file and produces an xml output which shows the structure of the source xml file. I want to include the following information in the output: which of the output-nodes has any...
0
8045
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7981
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8462
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8127
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8320
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6803
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2458
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.