Click here to Skip to main content
16,016,227 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: Editable XML from MSXML Pin
Michael A. Barnhart29-Mar-02 3:14
Michael A. Barnhart29-Mar-02 3:14 
QuestionParsing takes too long - How to speed-up??? Pin
Rybeck25-Mar-02 6:29
Rybeck25-Mar-02 6:29 
AnswerRe: Parsing takes too long - How to speed-up??? Pin
Michael A. Barnhart27-Mar-02 11:44
Michael A. Barnhart27-Mar-02 11:44 
GeneralAn interesting example Pin
Michael A. Barnhart21-Mar-02 15:22
Michael A. Barnhart21-Mar-02 15:22 
GeneralXSLT to write links Pin
MS le Roux17-Mar-02 23:06
MS le Roux17-Mar-02 23:06 
GeneralRe: XSLT to write links Pin
David Wengier17-Mar-02 23:45
David Wengier17-Mar-02 23:45 
GeneralRe: XSLT to write links Pin
MS le Roux18-Mar-02 5:00
MS le Roux18-Mar-02 5:00 
GeneralRe: XSLT to write links Pin
Paul Watson20-Mar-02 22:12
sitebuilderPaul Watson20-Mar-02 22:12 
MarSCoZa wrote:
<para>The earth rotates.

Technically that kind of XML is not really valid.

e.g.

<para>
The
<link url="earth.htm">earth</link>
rotates.
</para>

The The and Rotates PCDATA sections are "floating".

The reason being that an element can either only contain PCDATA or child-elements. It cannot contain both. Think about creating a DTD which defines that... You cannot really. The DTD element definition cannot contain PCDATA and an elements name.

However XML is quite forgiving in this case (which is strange considering it's normally very unforgiving nature) and you can use the following XSL to transform it.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:template match="/">
		<html>
			<head>
			</head>
			<body>				
				<xsl:apply-templates />
			</body>
		</html>
	</xsl:template>
	
	<xsl:template match="link">
		<a>
			<xsl:attribute name="href">
				<xsl:value-of select="@url" />
			</xsl:attribute>
		<xsl:value-of select="."/>
		</a>
	</xsl:template>
</xsl:stylesheet>


The key is templates. I used to hate them and thought they were these daft, never used bits of XSL. Until I figured out how they worked and went "oooohh yes!" Smile | :)

Enjoy!

regards,
Paul Watson
Bluegrass
Cape Town, South Africa

The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
GeneralRe: XSLT to write links Pin
Atlantys8-Apr-02 6:26
Atlantys8-Apr-02 6:26 
GeneralTrying to write a filter Pin
Christian Graus13-Mar-02 9:41
protectorChristian Graus13-Mar-02 9:41 
GeneralRe: Trying to write a filter Pin
MS le Roux13-Mar-02 19:08
MS le Roux13-Mar-02 19:08 
GeneralRe: Trying to write a filter Pin
Christian Graus13-Mar-02 20:28
protectorChristian Graus13-Mar-02 20:28 
GeneralRe: Trying to write a filter Pin
Paul Watson14-Mar-02 0:46
sitebuilderPaul Watson14-Mar-02 0:46 
GeneralRe: Trying to write a filter Pin
Michael A. Barnhart14-Mar-02 0:53
Michael A. Barnhart14-Mar-02 0:53 
GeneralRe: Trying to write a filter Pin
Christian Graus14-Mar-02 3:12
protectorChristian Graus14-Mar-02 3:12 
GeneralVoice XML Pin
Adrian Metcalfe13-Mar-02 5:36
Adrian Metcalfe13-Mar-02 5:36 
GeneralRe: Voice XML Pin
Jamie Hale28-Mar-02 11:05
Jamie Hale28-Mar-02 11:05 
Generalvalidating XML in .NET Pin
SimonS13-Mar-02 0:22
SimonS13-Mar-02 0:22 
GeneralRe: validating XML in .NET Pin
Not Active13-Mar-02 5:35
mentorNot Active13-Mar-02 5:35 
GeneralInclude files, but in XSL Pin
Paul Watson12-Mar-02 4:29
sitebuilderPaul Watson12-Mar-02 4:29 
GeneralRe: Include files, but in XSL Pin
MS le Roux12-Mar-02 7:25
MS le Roux12-Mar-02 7:25 
GeneralRe: Include files, but in XSL Pin
Paul Watson12-Mar-02 19:49
sitebuilderPaul Watson12-Mar-02 19:49 
GeneralRe: Include files, but in XSL Pin
Paul Watson12-Mar-02 19:41
sitebuilderPaul Watson12-Mar-02 19:41 
GeneralWeird behavior reading attributes Pin
Michael Dunn8-Mar-02 6:24
sitebuilderMichael Dunn8-Mar-02 6:24 
GeneralRe: Weird behavior reading attributes Pin
Daniel Turini8-Mar-02 7:20
Daniel Turini8-Mar-02 7:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.