473,406 Members | 2,705 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,406 software developers and data experts.

how to apply xsl stylesheet only for a particaular tag

Hi all,
H i have an xslt file which does some function say to suppress the
empty tags in complex elements.
for ex if i have an xml
<A>
<B>value</B>
<ReturnData>
<C1>value</C1>
<C2>value</C2>
<C3/>
</ReturnData>
<D>
<D1>value</D1>
<D2>value</D2>
<D3/>
</D>
<E>value</E>
</A>
now the o/p should be
<A>
<B>value</B>
<ReturnData>
<C1>value</C1>
<C2>value</C2>
</ReturnData>
<D>
<D1>value</D1>
<D2>value</D2>
<D3/>
</D>
<E>value</E>
</A>

basically we want to suppress any empty tags within <ReturnDatatag.
this <ReturnDatatag is common in all responses that we deal with
however the structure n the name of elements within <ReturnDatatag
varies with every response.
now we would like to have a generic xslt which we can apply to all the
response xmls
but it should suppress the empty tags within <ReturnDatatag only
regards
ashish

Aug 31 '06 #1
3 1083


as**********@googlemail.com wrote:

H i have an xslt file which does some function say to suppress the
empty tags in complex elements.
for ex if i have an xml
<A>
<B>value</B>
<ReturnData>
<C1>value</C1>
<C2>value</C2>
<C3/>
</ReturnData>
<D>
<D1>value</D1>
<D2>value</D2>
<D3/>
</D>
<E>value</E>
</A>
now the o/p should be
<A>
<B>value</B>
<ReturnData>
<C1>value</C1>
<C2>value</C2>
Start with the identity transformation template

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

then make sure that those empty child elements of ReturnData elements
are not processed further e.g.

<xsl:template match="ReturnData/*[not(node())]"/>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 31 '06 #2
Thanks Mr. Martin...

one more issue i am facing is that there can be many levels of nesting
inside the "ReturnData" element as shown below:
....
....
<ReturnData>
<C1>value</C1>
<C2>value</C2>
<C3/>
<C4>
<D1>value</D1>
<D2>value</D2>
<D3/>
<C4>
</ReturnData>
....

How to use the xsl code for this nesting mode?

Sep 1 '06 #3


as**********@googlemail.com wrote:

one more issue i am facing is that there can be many levels of nesting
inside the "ReturnData" element as shown below:
Then
<xsl:template match="ReturnData//*[not(node())]"/>
instead of my ealier suggestion should do what you want.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 1 '06 #4

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

Similar topics

1
by: Stefan Siegl | last post by:
Hello, I am trying to learn XSLT to use it in another project. I start reading the book "Java and XSLT" and tried the examples and they are went quite fine (how suprising *g*). Then I tried...
1
by: Daryl | last post by:
Hello I am using apply-templates and would like to pass a parameter to the template using with-param. Using call-template passes the parameter, but when I use apply-templates, the parameter seems...
1
by: Vijay singh | last post by:
Hi wonder if anybody can clear by doubt XML file : <score id="1"> <film>A Little Princess</film> <composer>Patrick Doyle</composer>
3
by: bjam | last post by:
Help! The apply-templates function is not currently allowing me to select a specific template... eventhough I tried putting a select statement, it does not seem to work??? Can someone help show...
3
by: Blaise Garant | last post by:
Hi I've made a stylesheet to transform my data into XSL-FO. This stylesheet used to work with MSXSL 4.0 but I've got some issues in ..NET. First, I changed removed all the "node-set()" function...
2
by: jimbo_vr5 | last post by:
Hey I think i've figured out the idea behind apply-templates. But going through the tutorial on <http://www.w3schools.com/xsl/xsl_apply_templates.asp> theres simply just something that i dont...
3
by: Frank Rizzo | last post by:
I've added a .css stylesheet to my asp.net project. How can I make vs.net apply the stylesheet to all new pages (or even current) that I create? Thanks
2
by: RccH | last post by:
Beginner using xslt... So. I have an XML file which has a link into xslt file like following... <?xml version='1.0' encoding='utf-8' ?> <?xml-stylesheet type="text/xsl" href="transform.xsl"?>...
4
by: C.W.Holeman II | last post by:
I am using Firefox 2.0.0.3 on MSWindows. I have an XML file http://emle.sourceforge.net/emle020000/testb.xml which invokes an XSLT file http://emle.sourceforge.net/emle020000/testb.xsl <?xml...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.