![]() |
|
|
|
#1 |
|
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 Newbie |
|
|
|
|
#2 |
|
Posts: n/a
|
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". |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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 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/ |
|
|
|
#5 |
|
Posts: n/a
|
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. |
|
|
|
#6 |
|
Posts: n/a
|
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 |
|