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

Suppressing the display of elements

Jim
Hi

I have foo.xml:

<file>
<area1>
<name>John</name>
<age>22</age>
</area1>

<area2>
<weight>200</weight>
<height>73in</height>
</area2>
</file>

I have foo.xsl:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="file/area1">
<xsl:value-of select="name"/>
<xsl:value-of select="age"/>
</xsl:template>

<xsl:template match="file/area2">
<xsl:value-of select="height"/>
<xsl:value-of select="weight"/>
</xsl:template>

</xsl:stylesheet>
I only want area1 and area2 information displayed. However, when I
apply this stylesheet, I get everything. How do I ignore/suppress area2
in foo.xml?

Jul 20 '05 #1
3 1192
That's because it is using the built in templates since you haven't
explicitly called <xsl:apply-templates ../> for each area!

Add this below your <xsl:output ... /> and it should work.

<xsl:templates match="/">
<xsl:apply-templates select="file/area1" />
<xsl:apply-templates select="file/area2" />
</xsl:template>

b0yce

"Jim" <no@no.no> wrote in message news:c8**********@gargoyle.oit.duke.edu...
Hi

I have foo.xml:

<file>
<area1>
<name>John</name>
<age>22</age>
</area1>

<area2>
<weight>200</weight>
<height>73in</height>
</area2>
</file>

I have foo.xsl:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="file/area1">
<xsl:value-of select="name"/>
<xsl:value-of select="age"/>
</xsl:template>

<xsl:template match="file/area2">
<xsl:value-of select="height"/>
<xsl:value-of select="weight"/>
</xsl:template>

</xsl:stylesheet>
I only want area1 and area2 information displayed. However, when I
apply this stylesheet, I get everything. How do I ignore/suppress area2
in foo.xml?

Jul 20 '05 #2


Jim wrote:

I have foo.xml:

<file>
<area1>
<name>John</name>
<age>22</age>
</area1>

<area2>
<weight>200</weight>
<height>73in</height>
</area2>
</file>

I have foo.xsl:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="file/area1">
<xsl:value-of select="name"/>
<xsl:value-of select="age"/>
</xsl:template>

<xsl:template match="file/area2">
<xsl:value-of select="height"/>
<xsl:value-of select="weight"/>
</xsl:template>

</xsl:stylesheet>
I only want area1 and area2 information displayed. However, when I
apply this stylesheet, I get everything. How do I ignore/suppress area2
in foo.xml?


If you use an empty template
<xsl:template match="area2" />
matching area2 you will not get any output.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3
Jim
Martin Honnen wrote:

If you use an empty template
<xsl:template match="area2" />
matching area2 you will not get any output.


Excellent, thank you.

Jim

Jul 20 '05 #4

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

Similar topics

13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
7
by: chil | last post by:
I want to open a popup window and the window should not display the URL information anywhere on the browser. Can you suggest.
6
by: snacktime | last post by:
I've searched and searched and have not found a solution to suppress the margin on form or href tags so that there is no space before or after the tag. The only way I have found to do this is to...
7
by: Stefan Finzel | last post by:
Hi, is there a way to change the display property on Windows Mobile 2003 SE Mobile/Pocket Internet Explorer? See following example. Please note: visibilty property has the same problem. Is...
4
by: T Conti | last post by:
Howdy: I am currently writing a .Net handler to replace an ASP page. The ASP module used a COM dll to format XML. This dll was pretty robust and it auto-suppressed empty elements and...
40
by: Dave Hansen | last post by:
Please note crosspost. Often when writing code requiring function pointers, it is necessary to write functions that ignore their formal parameters. For example, a state machine function might...
2
by: Geoff Hanna | last post by:
I have a complicated form that manages lots of panels. When the user wants a new panel, the old one is disposed and a new one constructed so only one panel is actually in existance at one time....
18
by: R. P. | last post by:
I wonder how to indicate in a stylesheet that character entities in an element are not to be transformed as would be the case in XML-to-XML transforms. I want to keep those &amp; &quot; and other character...
5
by: Don Li | last post by:
Hi, A web app server package that I'm using includes a bunch of open source UI components (heavy with javascripts). Inevitably it has bugs, e.g. "undefined" is null or not an object. This...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.