473,387 Members | 1,282 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.

Using XSLT to Order Nodes

The answer to this is probably obvious, but I'm somewhat new to XSLT and can't
find it.

I need to sort a set of nodes within a document, e.g.

<A>
<B/>
<C>
<D>3</D>
<D>2</D>
<D>4</D>
<D>1</D>
</C>
<F/>
</A>

How should I construct an XSLT to output

<A>
<B/>
<C>
<D>1</D>
<D>2</D>
<D>3</D>
<D>4</D>
</C>
<F/>
</A>

where everything outside C is arbitrary? I know about sort, but I don't know how
to output everything around C.

Thanks for any help.

--
Posted via a free Usenet account from http://www.teranews.com

Jul 20 '06 #1
5 2025
Newbie wrote:
where everything outside C is arbitrary? I know about sort, but I don't
know how to output everything around C.
Start with the "identity stylesheet", then add a template which will do
the special handling needed for match="C".
Jul 20 '06 #2
Joe Kesselman wrote:
Start with the "identity stylesheet", then add a template which will do
the special handling needed for match="C".
Found a reference to "identity stylesheet" in
http://hacks.oreilly.com/pub/h/2070, but a comment warns about problems with
CDATA. What is the problem here (I can't find any more info), and is there an
easy way around it (I can't control the input)?

--
Posted via a free Usenet account from http://www.teranews.com

Jul 20 '06 #3


Newbie wrote:
Found a reference to "identity stylesheet" in
http://hacks.oreilly.com/pub/h/2070, but a comment warns about problems
with CDATA. What is the problem here (I can't find any more info), and
is there an easy way around it (I can't control the input)?
The XPath/XSLT data model does not know CDATA sections, it only knows
text nodes. If you transform XML to XML with a simple identity
transformation then CDATA sections might not be preserved but in terms
of well-formedness everything will be fine, only instead of having a
CDATA section to escape things character/entity references will be used
to escape things.
You can however define
<xsl:output cdata-section-elements="put element names here" />
to have the XSLT processor create CDATA sections as element contents
when serializing that result tree.
That way you can determine which elements in the result should have
CDATA section content. Only it does not help if you want to write a
generic stylesheet processing abritary elements you don't know the names of.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '06 #4
Of course no modern XML application should care whether you've used
CDATA sections or ordinary text with character-by-character escaping
when needed.

Unfortunately some tools carried over from the HTML world are broken in
that regard.
Jul 20 '06 #5
Martin Honnen wrote:
The XPath/XSLT data model does not know CDATA sections, it only knows
text nodes. If you transform XML to XML with a simple identity
transformation then CDATA sections might not be preserved but in terms
of well-formedness everything will be fine, only instead of having a
CDATA section to escape things character/entity references will be used
to escape things.
Thank you, hopefully this will suffice.

--
Posted via a free Usenet account from http://www.teranews.com

Jul 20 '06 #6

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

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
5
by: K. N. | last post by:
Is there any good and fast Python module for XSLT processing ? I'm going to use XML and XSLT to generate web pages, so I need XSLT processor that will be able to transform for example a DOM object...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
4
by: cyclops | last post by:
I'm trying to do XML + XSLT -> Another XML. The source XML contains multiple namespaces and XSLT will handle all possible tags under each name space. ----source---- <document xmlns="..."...
4
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
2
by: Jon Martin Solaas | last post by:
Hi, I have a general document somewhat like this: -------------------------------------- <root> <level1> <level2> <interestingstuff number="2"/> <interestingstuff number="3"/>...
1
by: Foxpointe | last post by:
Given some arbitrary XHTML, I'd like to obtain a 'simplified' XHTML result which strips out a large subset of standard elements and attributes - but not all. The main things I would like to...
1
by: Daniel Hilgarth | last post by:
Hello, I am currently trying to use XSLT for the creation of multiple HTML-files from a single XML-File. This HTML-files need to have links to each other. The following information might be...
6
by: kluge.wolfram | last post by:
Hi, i get stucked on a transformation problem using XSLT. What i need is to copy an XML Tree to an output XML without any automatic changes. Since i used <xsl:copyor <xsl:copy-ofthere occur...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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: 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:
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
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.