473,320 Members | 1,854 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,320 software developers and data experts.

xsl apply-templates select=not(...)

Hello,

I have a XML document which is typically :

<course>
<section>
<title>Foo</title>
There comes the text
</section>
<section>
<title>Foo</title>
There comes the text
</section>
</course>

I'd like to indent the "There comes the text" part, but not the title.
This is what I tried, but unfortunately it doesn't work :

<xsl:template match="course/section">
<xsl:apply-templates select="title"/>
<ul>
<xsl:apply-templates select="*[not(title)]"/>
</ul>
</xsl:template>

Could someone give me advice on this. I'd like to avoid the for-if
combination if possible.

Thanks in advance,
--
_|_|_| CnS
_|_| for(n=0;b;n++)
_| b&=b-1; /*pp.47 K&R*/
Jul 20 '05 #1
4 5984
In article <Xn****************************@213.228.0.136>,
Cyrille \"cns\" Szymanski <cn**@cns.invalid> wrote:

% I have a XML document which is typically :
%
% <course>
% <section>
% <title>Foo</title>
% There comes the text
% </section>

From a design perspective, I think you're better off if you make
section have element content (that is, you wrap all your text in
additional elements). For one thing, if that's valid, then this must
also be valid

% <section>
Here is some text
% <title>Foo</title>
% </section>

which is probably not desirable. For another, you have to guess at the
structure if there's more than one paragraph of data, which goes against
the point of using xml in the first place.

% I'd like to indent the "There comes the text" part, but not the title.
% This is what I tried, but unfortunately it doesn't work :
%
% <xsl:template match="course/section">
% <xsl:apply-templates select="title"/>
% <ul>
% <xsl:apply-templates select="*[not(title)]"/>

Try select="node()[not(title)]", or if it's really just text,
select="text()".
--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #2
Patrick TJ McPhee wrote:
In article <Xn****************************@213.228.0.136>,
Cyrille \"cns\" Szymanski <cn**@cns.invalid> wrote:
% I'd like to indent the "There comes the text" part, but not the title.
% This is what I tried, but unfortunately it doesn't work :
%
% <xsl:template match="course/section">
% <xsl:apply-templates select="title"/>
% <ul>
% <xsl:apply-templates select="*[not(title)]"/>

Try select="node()[not(title)]",


This selects all child nodes of section that have no _child node(s)_
called title. Try "node()[not(self::title)]" instead.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)

Jul 20 '05 #3
> Patrick TJ McPhee wrote:
In article <Xn****************************@213.228.0.136>,
Cyrille \"cns\" Szymanski <cn**@cns.invalid> wrote:
% I'd like to indent the "There comes the text" part, but not the
title. % This is what I tried, but unfortunately it doesn't work :
%
% <xsl:template match="course/section">
% <xsl:apply-templates select="title"/>
% <ul>
% <xsl:apply-templates select="*[not(title)]"/>

Try select="node()[not(title)]",


This selects all child nodes of section that have no _child node(s)_
called title. Try "node()[not(self::title)]" instead.


Thanks. In fact I had added the self:: part since I read a message that
pointed out this issue.

--
_|_|_| CnS
_|_| for(n=0;b;n++)
_| b&=b-1; /*pp.47 K&R*/
Jul 20 '05 #4
> From a design perspective, I think you're better off if you make
section have element content (that is, you wrap all your text in
additional elements). For one thing, if that's valid, then this must
also be valid


You're absolutely right, unfortunately, I am not free to do so since I'm
using existing XML documents that are already written that way.

Thanks for help,
--
_|_|_| CnS
_|_| for(n=0;b;n++)
_| b&=b-1; /*pp.47 K&R*/
Jul 20 '05 #5

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

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
1
by: Christopher Benson-Manica | last post by:
IE 5.0 apparently does not support the apply() method for function objects - the following fails: function foo() { alert( this.length ); } foo.apply( ); Is there a convenient way to add an...
2
by: Dale Anderson | last post by:
I have a schema that I'm trying to read. The schema has an element named 'GrantApplication' and one with a namespace prefix named 'SF424:GrantApplication'. When I try to read this schema in, I...
1
by: Trent | last post by:
Hello,everyone. I'm setting a db2 replication environment using UDB version 8.1.5 running on Windows 2000 servers. The source server is on a Windows server with the capture program running while...
3
by: almousawi | last post by:
I am working on a DB2 replication program that used to work. I ran the "warm" capture program to get a cold start and I am running the apply program, but, the apply does not replicate the data. I...
4
by: esmith2112 | last post by:
Having a bear of a time trying to implement replication under 8.2 environment. I've created all of the control structures on both source and target database and can actually see data being staged...
0
by: Paul | last post by:
Snippet from web.config: <startup> <supportedRuntime version="v1.0.3705" /> <requiredRuntime version="v1.0.3705" safemode="true"/> </startup> <runtime> <assemblyBinding...
0
by: mdb_1974 | last post by:
Hello I tried to do an initial full refresh but I failed - nothing happens (no error at all). Apply works without errors. Details of my environment: I have the following replication scenario:...
3
by: Jeff Stewart | last post by:
I've been working with the JavaScript Shell in Firefox on a mad-scientist problem I've had in my head. Assume a function named 'object' that is designed to create an object based on a prototype...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.