detecting non-existent attribute in XSL

G

Greg Sandell

Suppose I have the following XML:

<root>
<homepage>
<title country="France">Welcome to our French friends:
Homepage</welcome>
<title country="England">Welcome to our English friends:
Homepage</welcome>
</homepage>
<aboutUsPage>
<title>Welcome to our Friends: About Us</title>
</aboutUsPage>
</root>

The idea here is that the home page has a country-specific title, and
the About Us page has one title for all countries. Imagine much more
XML with lots of other nodes marked up in this way.

What I want is an XSL template that will give me all the nodes that
are specific to a country, plus all the country-non-specific nodes.
Here is some pseudo XSL for what I would like to do (using an
English-specific example):

<xsl:template match="//node()[@country = 'England'] |
//node()[isnull(@country)]">
</xsl:template>

Of course, there is no such thing as an isnull() function. But is
there SOME way for me to detect nodes that lack a country attribute?

Any solution which does not require a change to my XML would be
appreciated. (i.e. I don't want to add "country=all" to the generic
nodes.)

Thanks,
Greg Sandell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top