Hi @all,
I have a trivial question, but I cannot find any answer :(
<xsl:template match="note">
<b>Note:</b>
</xsl:template>
<xsl:template match="note[@role = 'para']">
<p><!-- CALL <xsl:template match="note"FRO M HERE --></p>
</xsl:template>
Please have a look at this tiny piece of code. How can I call the
first template from the second specialized one?
NOTE: I cannot change the first one!
Many thanks,
Kirsten 7 3380 tt******@gmx.de wrote:
I have a trivial question, but I cannot find any answer :(
<xsl:template match="note">
<b>Note:</b>
</xsl:template>
<xsl:template match="note[@role = 'para']">
<p><!-- CALL <xsl:template match="note"FRO M HERE --></p>
</xsl:template>
Please have a look at this tiny piece of code. How can I call the
first template from the second specialized one?
NOTE: I cannot change the first one!
Well if your sample XML has e.g.
<note role="para">
<note/>
</note>
then <xsl:apply-templates/or <xsl:apply-templates select="note"/will
do. But if you do not have nested note elements then it is not possible,
unless you name the first template.
--
Martin Honnen http://JavaScript.FAQTs.com/
As Martin said, the simplest solution is to use the xsl:call-template
operation and give the template you want to call a name.
Similar things can be accomplished with modes, but that would be
overkill for this simple case.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
On 29 Mai, 19:00, Joseph Kesselman <keshlam-nos...@comcast. netwrote:
As Martin said, the simplest solution is to use the xsl:call-template
operation and give the template you want to call a name.
Similar things can be accomplished with modes, but that would be
overkill for this simple case.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
I am really surprised that this cannot be done (easily).
My structure is like this:
<note role="para">
I hope it works.
</note>
What I want is:
1. <xsl:template match="note[@role = 'para']"is executed
2. <xsl:template match="note"is executed
Of course, for the same element.
Background:
I am trying to print additional letters, if role="para" without
loosing the ability of "<xsl:templ ate match="note">".
My use case is not that simple. I use DocBook XSL and I wanna modify
the output of a simple element ("note"), if I use a special role.
However, the DocBook XSL rule for "note" must be executed as well. tt******@gmx.de wrote:
1. <xsl:template match="note[@role = 'para']"is executed
2. <xsl:template match="note"is executed
In addition to the two options I pointed out... It sounds like this is a
perfect opportunity to learn about the apply-imports operation. Write
your stylesheet so it imports the DocBook stylesheet that defines #2
above, and write your new #1 template so it calls <xsl:apply-importsat
the point where you want to hand off to DocBook's standard processing.
That's about as close as XSLT comes to OOP-style inheritance and super()
invocation.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden tt******@gmx.de wrote:
On 29 Mai, 19:00, Joseph Kesselman <keshlam-nos...@comcast. netwrote:
>As Martin said, the simplest solution is to use the xsl:call-template operation and give the template you want to call a name.
Similar things can be accomplished with modes, but that would be overkill for this simple case.
-- Joe Kesselman / Beware the fury of a patient man. -- John Dryden
I am really surprised that this cannot be done (easily).
My structure is like this:
<note role="para">
I hope it works.
</note>
What I want is:
1. <xsl:template match="note[@role = 'para']"is executed
2. <xsl:template match="note"is executed
Of course, for the same element.
Background:
I am trying to print additional letters, if role="para" without
loosing the ability of "<xsl:templ ate match="note">".
My use case is not that simple. I use DocBook XSL and I wanna modify
the output of a simple element ("note"), if I use a special role.
However, the DocBook XSL rule for "note" must be executed as well.
If you can alter the first template to add a name attribute then you can go
<xsl:template match="note" name="foo">
....
<xsl:template match="note[@role = 'para']">
stuff
<xsl:call-template name="foo"/>
if you are in a position that you have write access to the second
template but not the first (because you are over-riding some public xslt
file for example) that is the exact use case for xsl:apply-imports as
others have mentioned.
in one file you have
<xsl:template match="note">
then in the file that imports this you have
<xsl:template match="note[@role = 'para']">
stuff
<xsl:apply-imports/>
If you are using xslt2 you can use <xsl:next-match/instead of
<xsl:apply-imports/which works (more or less) the same way, but
without the requirement that the templates are in separate files.
David
-- http://dpcarlisle.blogspot.com
On 29 Mai, 22:54, David Carlisle <david-n...@dcarlisle. demon.co.uk>
wrote:
tthun...@gmx.de wrote:
On 29 Mai, 19:00, Joseph Kesselman <keshlam-nos...@comcast. netwrote:
As Martin said, the simplest solution is to use the xsl:call-template
operation and give the template you want to call a name.
Similar things can be accomplished with modes, but that would be
overkill for this simple case.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
I am really surprised that this cannot be done (easily).
My structure is like this:
<note role="para">
I hope it works.
</note>
What I want is:
1. <xsl:template match="note[@role = 'para']"is executed
2. <xsl:template match="note"is executed
Of course, for the same element.
Background:
I am trying to print additional letters, if role="para" without
loosing the ability of "<xsl:templ ate match="note">".
My use case is not that simple. I use DocBook XSL and I wanna modify
the output of a simple element ("note"), if I use a special role.
However, the DocBook XSL rule for "note" must be executed as well.
If you can alter the first template to add a name attribute then you can go
<xsl:template match="note" name="foo">
...
<xsl:template match="note[@role = 'para']">
stuff
<xsl:call-template name="foo"/>
if you are in a position that you have write access to the second
template but not the first (because you are over-riding some public xslt
file for example) that is the exact use case for xsl:apply-imports as
others have mentioned.
in one file you have
<xsl:template match="note">
then in the file that imports this you have
<xsl:template match="note[@role = 'para']">
stuff
<xsl:apply-imports/>
If you are using xslt2 you can use <xsl:next-match/instead of
<xsl:apply-imports/which works (more or less) the same way, but
without the requirement that the templates are in separate files.
David
--http://dpcarlisle.blog spot.com- Zitierten Text ausblenden -
- Zitierten Text anzeigen -
Nice!
<xsl:apply-imports/and <xsl:next-match/really work for my problem!
I saw "apply-imports" already, but didn't expect that it works for me.
I thought that there must be a generic solution which is independent
from "imports". I guess, that is why next-match was introduced in
XSLT2.
Thank you! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jean-Christophe Michel |
last post by:
Hi,
In a complex merging of two (non ordered) xml files
i need to keep track of the elements of the second tree that were already
merged with first tree, to copy only unused elements at the end.
I tried two solutions:
* first is to 'substract' the used element from existing tree
|
by: Sebek |
last post by:
Hello,
I'm transforming a XML document in XHTML but I have problems using
sub-strings, it will be clearer with an exemple:
What I have:
<form href="identification.php?PHPSESSID=134134&page=2¶m=3" >
</form>
what I want:
|
by: Gadrin77 |
last post by:
as a newbie to XSL, is it possible to mimic a SELECT/CASE statement
using
XSL?
I tried a quickie and I kept getting errors either using PARAM or
WITH-PARAM
in the wrong place or VARIABLE. I ended up using .createProcessor and
doing
all the work behind the scenes in my programming language, then using
the
|
by: Norman Barker |
last post by:
Hi,
I am trying to use the DVC algorithm detailed at
http://www.topxml.com/code/default.asp?p=3&id=v20020107050418
had a few problems, the document is structured as
:
:
<sql:row>
<sql:date>YYYYMMMDD</sql:date>
|
by: Paul Guz |
last post by:
I've discovered a quirk of .Net System.Xml.Xsl.XSLTransfrom that doesn't
seem to exist in the MSXML2 transformation.
When calling a recursive template for the first time, don't pass a parameter
value using a variable with the same name as the parameter. This seems to
cause the original value to remain constant in all recursive calls, even if
you modify that value inside the template. To demonstrate:
<xsl:template match="/">...
| |
by: William Krick |
last post by:
I am writing an XSL transform that converts XML data about vehicles
into XML data that will fill printed forms.
The default form can handle up to 5 vehicles which I handle using
subscripts...
<xsl:for-each select="VEHICLE">
<!-- spit out some stuff about this vehicle -->
</xsl:for-each>
<xsl:for-each select="VEHICLE">
|
by: will |
last post by:
All
Hope you can help with the following..
I am using recursion to calculate the sum of
DEBT_INPUT_VALUE_BEFORE_SPLIT * CTXR_TAX_RATE elements, along the lines
of sum(a*b)
ie
|
by: monmonja |
last post by:
Hi i'm new to xsl and i have been using smarty php templating but its
just so hard to read codes in smarty/php/flash than xml/xsl/flash, i
rather sacrifice speed then not being able to read code after 3 months.
So my problem goes like this.
I have an xml that like this
<avatar>
<avatarId>1</avatarId>
<avatarName>MyNewAvatar</avatarName>
<avatarFile>
<fileName>MyNewAvatar.swf</fileName>
|
by: felciano |
last post by:
Hello --
I am trying to use XSL to process Amazon wishlist data to sort the
results by type (Apparel, then Books, then DVDs, etc). Amazon's web
services chunk up results in multiple pages of fixed size, e.g. 55
items gets returned in 5 XML pages of 10 items and a 6th of 5 items.
Each page is returned from a distinct URL call with a PageNum
parameter.
I've been trying to adapt a technique described at...
|
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,...
|
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,...
| |
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |