472,981 Members | 1,416 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

XSL: NOT equal checking for node?

Hi,

I need to know how I can check to see if a particular node is NOT equal
to a SET of values.

i.e. a valid form of : <xsl:template match!="H" && match!="Y"&&
match!="Z">

I have an XML document of the foll format:

<ROOT>
<A>1</A>
<B>2</B>
<C>3</C>
.....
<H>4</H>
....
</ROOT>

I need to transform this into another format. Only the nodes <H>, <X>,
<Z> need special handling, which i refer to, via a corresponding
template calls.

All the other nodes, need to be transformed like this:

<A>1</A> becomes <A><Value>1</Value></A>

My xsl looks something like this:

<xsl:template match="/">
<NEWFORM>
<xsl:apply-templates/>
</NEWFORM>
</xsl:template>

/****template calls for H, X, Z**********/

<xsl:template match="H">
//special handling for <H>
</xsl:template>

How do I say: "for all nodes that are NOT H, X and Z, do this:" ?

something like:

for each child of root
not equal to X, H, Z
do the following:

Thanks for any help
Rohit.

Dec 1 '05 #1
7 10283
This is basics -- you need to read a good book.

Use the XPath not() function and the "=" operator.
Almost never use the "!=" operator, especially if you are not 100% sure you
know what you're doing...
Cheers,
Dimitre Novatchev.
<Pi******@hotmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hi,

I need to know how I can check to see if a particular node is NOT equal
to a SET of values.

i.e. a valid form of : <xsl:template match!="H" && match!="Y"&&
match!="Z">

I have an XML document of the foll format:

<ROOT>
<A>1</A>
<B>2</B>
<C>3</C>
....
<H>4</H>
...
</ROOT>

I need to transform this into another format. Only the nodes <H>, <X>,
<Z> need special handling, which i refer to, via a corresponding
template calls.

All the other nodes, need to be transformed like this:

<A>1</A> becomes <A><Value>1</Value></A>

My xsl looks something like this:

<xsl:template match="/">
<NEWFORM>
<xsl:apply-templates/>
</NEWFORM>
</xsl:template>

/****template calls for H, X, Z**********/

<xsl:template match="H">
//special handling for <H>
</xsl:template>

How do I say: "for all nodes that are NOT H, X and Z, do this:" ?

something like:

for each child of root
not equal to X, H, Z
do the following:

Thanks for any help
Rohit.

Dec 1 '05 #2
Hi,

Thanks for your reply.

I just reread my post - i hope I didn't mislead you my saying
"particular node is NOT equal to a SET of values."

Just to clarify, i really want to be looking for all nodes other than
X, Y, and Z, and not their values as I had posted.

been struggling with this for a while, could you post a snippet plz?

Dec 1 '05 #3
Pi******@hotmail.com wrote:
Just to clarify, i really want to be looking for all nodes other than
X, Y, and Z, and not their values as I had posted.


*[not(self::X)][not(self::Y)][not(self::Z)]
--
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
(Thomas Tallis, 40-part motet)
Dec 1 '05 #4
> How do I say: "for all nodes that are NOT H, X and Z, do this:" ?

In XSLT one doesn't need to specifically write this.

you will have two templates:

<xsl:template match="*">
<!-- Whatever general transformation necessary here -->

</xsl:template>

<xsl:template match="H | X | Z">
<!-- A more specialized transformation here -->

</xsl:template>

The second template overrides the first for elements of type H, X, Z.

Just try it :o)
Cheers,
Dimitre Novatchev

<Pi******@hotmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hi,

I need to know how I can check to see if a particular node is NOT equal
to a SET of values.

i.e. a valid form of : <xsl:template match!="H" && match!="Y"&&
match!="Z">

I have an XML document of the foll format:

<ROOT>
<A>1</A>
<B>2</B>
<C>3</C>
....
<H>4</H>
...
</ROOT>

I need to transform this into another format. Only the nodes <H>, <X>,
<Z> need special handling, which i refer to, via a corresponding
template calls.

All the other nodes, need to be transformed like this:

<A>1</A> becomes <A><Value>1</Value></A>

My xsl looks something like this:

<xsl:template match="/">
<NEWFORM>
<xsl:apply-templates/>
</NEWFORM>
</xsl:template>

/****template calls for H, X, Z**********/

<xsl:template match="H">
//special handling for <H>
</xsl:template>

How do I say: "for all nodes that are NOT H, X and Z, do this:" ?

something like:

for each child of root
not equal to X, H, Z
do the following:

Thanks for any help
Rohit.

Dec 1 '05 #5
Johannes Koch wrote:
Pi******@hotmail.com wrote:
Just to clarify, i really want to be looking for all nodes other than
X, Y, and Z, and not their values as I had posted.


*[not(self::X)][not(self::Y)][not(self::Z)]


Probably far easier is to declare the null template for the unwanted
element types:

<xsl:template match="X|Y|Z"/>

///Peter
--
XML FAQ: http://xml.silmaril.ie/

Dec 1 '05 #6
Thanks. much better. The <xsl:template match="*"> seems to fit my
needs.

I have run into another problem,

1) how do I call the * template?

I'm need to convert all tags (other than those with special handling)
of the form
<A>1234<A>

to

<TAG>
<NAME>A</NAME>
<VALUE>1234</VALUE>
</TAG>

<xsl:template match="INPUT">
<NEW>
<A><xsl:value-of select="A"/></A>
<B><xsl:value-of select="B"/></B>
<xsl:apply-templates select="* />
<xsl:apply-templates select="SPECIAL" />
</NEW>
</xsl:template>
-----------------------------------------------------------------------------------
I must have the special handling tag after the * handling.

2) The * template is included below. Is it correct to say node() to get
the node name?
-----------------------------------------------------------------------------------
<xsl:template match="*">
<xsl:variable name="tag_value">
<xsl:value-of select="."/>
</xsl:variable>
<FEATURE>
<MNEMONIC><xsl:value-of select='node()'/></MNEMONIC>
<VALUE><xsl:value-of select="$tag_value"/></VALUE>
</FEATURE>
</xsl:template>
---------------------------------------------------------------------------------------------------------

Dec 2 '05 #7
Pi******@hotmail.com wrote:
Thanks. much better. The <xsl:template match="*"> seems to fit my
needs.

I have run into another problem,

1) how do I call the * template?


You don't. It gets used by anything that is not otherwise matched by an
existing template.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Dec 3 '05 #8

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

Similar topics

15
by: Simon Harvey | last post by:
Hi everyone, I am fairly new to learning about xsl and xml, but one thing I have noticed is that anyone offering a tutorial or lesson on it seems to think that its the most incredible invention...
5
by: Kasp | last post by:
Hi, I have an XSL here...and though I understand XML, I am having a hard time understanding what this XSL does? Any help will be appreciated. TIA <xsl:stylesheet...
7
by: Sharon | last post by:
Hi, Is it possible to check parameters against other parameters, as in: <xsl:variable name="tableData"> <xsl:apply-templates select="general/data/rows/row/fvalues" mode="tableData" />...
14
by: inquirydog | last post by:
Hi- One frusterating thing for me with xsl is that I don't know how to make xslt throw some sort of exception when a value-of path does not exist. For instance, suppose I have the following...
6
by: Virginia Kirkendall | last post by:
Hi: I'm new with this & need help creating a XSL table that looks like the following: --------------------------------------------------------- | | | | | |...
6
by: Loopy | last post by:
I'm learning XML and XSL at the moment, but I still can't get my head around the concept of non-updatable variables. I know we can use recursion to cycle through a data structure and get the sum...
2
by: Norman Barker | last post by:
Hi, I have the following template <xsl:template match="midas:Request"> <xsl:variable name="var1" select="string(./midas:DataDescriptorGUID/@GUID)"/> <test> <result1><xsl:copy-of...
4
by: Tjerk Wolterink | last post by:
I've xml code like this: roles.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <roles xmlns="http://www.wolterinkwebdesign.com/xml/roles"> <!-- ! The admin role. ! And admin should have...
6
by: Christoph | last post by:
I'm trying to come up with a stylesheet where, when the rows are displayed, duplicate game names are not shown on subsequent rows. It works but doesn't work properly. If I sort the data using...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.