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

XSL Transform - Why is it writing out everything?

Hi

I have done the folloing XSLT and although it does write out my
elements as I want, it is also writing out ALL of the information in
the child nodes and attributes as it loops around.

Any ideas would be greatly appreciated - I am sure it is something
tiny!

Best regards and many thanks

Darren

<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="http://www.someurl.com/abc/2002/09"


<xsl:template
match="ns1:ABC_AccomAvailRS/ns1:AccommodationSearchResponse/ns1:Accommodations">

This is the start of our XSLT Transformation.<br />

<xsl:for-each select="ns1:AccommodationSegment">

<div name="dvHotelName"
style="background-color:#0033FF;padding:2px">
<xsl:value-of select="@AccommodationName"/> - <xsl:value-of
select="@OfficialRating"/>

</div>

<xsl:apply-templates />
<b>
<xsl:value-of select="ns1:Description"/>
</b>

</xsl:for-each>
<br />End of the XSLT Transformation

</xsl:template>

<xsl:template match="ns1:Image[1]">
<img src="{@ThumbnailURL}" />
</xsl:template>
</xsl:stylesheet>

May 24 '06 #1
4 1071
I have been able to put in additional templates as such:

<xsl:template match="ns1:Address" >

</xsl:template>

But I think that rather than solving the problem, this just hides it
doesn't it?

Thanks

Darren

May 24 '06 #2
daz_oldham wrote:
I have done the folloing XSLT and although it does write out my
elements as I want, it is also writing out ALL of the information in
the child nodes and attributes as it loops around.


"All the information in the child nodes" doesn't surprise me a lot.
You're doing an apply-templates recursion with no select, which defaults
to processing all the children, and the default template for elements
dumps the text content of the element. So add a select= attribute to the
apply to tell it which ones you actually want to examine, and/or provide
templates that treat those other elements the way you want them treated.

I can't explain "and attributes" in this case, but I suspect that's an
erroneous report rather than an actual behavior.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
May 24 '06 #3


daz_oldham wrote:

I have done the folloing XSLT and although it does write out my
elements as I want, it is also writing out ALL of the information in
the child nodes and attributes as it loops around.
<xsl:apply-templates />


You have not shown the input XML but if you do xsl:apply-templates then
that processes all child nodes (element nodes, text nodes, comment
nodes, processing instruction nodes) and as there are built-in default
templates (see
<http://www.w3.org/TR/xslt#built-in-rule>
) it is possible that for instance all text nodes are output.

So either do e.g.
<xsl:apply-templates select="someElement" />
meaning make sure that the above apply-templates applies only to the
element nodes you really want to be processed or make sure you override
the built-in templates e.g.
<xsl:template match="text()" />
so that for instance text nodes are not output.

Martin Honnen
http://JavaScript.FAQTs.com/
May 24 '06 #4
Spot on - thanks Martin, Joe for your help.

It is remembering these little obvious things that make a massive
difference - thanks :)

Darren

May 24 '06 #5

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

Similar topics

4
by: Luther Baker | last post by:
My team is using the FO library to generate PDFs. We are also required to use https. The XSL transform page fed into javax.xml.transform.Transformer starts with <?xml version="1.0"?>...
2
by: John Lehmann | last post by:
I have an interesting problem. I am performing an XSL transform using the System.Xml.Xsl.Transform class. I have a database that contains the XSL style sheet string. And it seems to work pretty...
3
by: Andy | last post by:
Hi all, I'm having a problem doing an Xslt transform in code. I've done it before, so I'm not really sure why its not working. The problem is that the result of the transform is an empty...
3
by: Daniel | last post by:
in C# how do i transform an xml document with an xsl document when my xml document is a string and my xsl document is a string? the msdn examples only show how to do it with steams and files. in my...
3
by: vitaly.tomilov | last post by:
I'm using an ASP.NET form to display data from my database table, and I'm doing it in the following way: XmlDataDocument doc = new XmlDataDocument(mydataSet); XPathNavigator nav =...
4
by: Dean Card | last post by:
Okay, so here is the situation. I have need to do some on-the-fly image creation. I have everything working great except for the last part of it, applying a perspective type transform to the...
6
by: Pete Verdon | last post by:
Summary: Can I do an XSLT transform, in the client, of a tree of nodes taken from the displayed page DOM in IE? This works in Firefox. Hi, I'm just starting the process of rewriting part of a...
1
by: Candle | last post by:
I am having a problem with writing an XSL Transform. Please help. Note: I know this a long post but I wanted to provide as must detail as possible. Any help would be appreciated. (Just started...
1
by: Candle | last post by:
I am having a problem with writing an XSL Transform. Please help. Note: I know this a long post but I wanted to provide as must detail as possible. Any help would be appreciated. (Just started...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
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...
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,...

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.