[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: Manipulating XSL element


Subject: Re: Manipulating XSL element
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 14 Aug 2000 19:21:24 +0100

Ciaran,

>	Is there any way to create an XML element
>without it being created by my XSL as an empty tag i.e.
><element/>

[You're still working on your XML parser in XSL, then?  It is still a bad
idea.  The more XML-like functionality you put in your pseudo-XML strings,
the worse an idea it gets.]

The only difference between an empty element and a non-empty element is
that an empty element has some content.  When you create an element using
xsl:element, then anything that you put within the xsl:element (that aren't
attributes) becomes its content.  For example:

<xsl:element name="tag">
  This is the content.
</xsl:element>

gives the output:

<tag>This is the content.</tag>

In your input pseudo-XML, you have the string coming in that looks like:

  "<tag>This is the content.</tag>"

***Note for confused readers: that <tag> and </tag> are not actually
openning and closing tags, the whole thing is a text string held in an
attribute value.***

You will need, in your XSLT-based XML parser, to look at the whole element
at once.  XSLT cannot create start tags and end tags separately, it creates
elements as a whole.  You need to write some XSLT code that looks at the
string and if the first bit is '<' + a name + '>', then take the substring
from the beginning of the string to the bit in the string that is '</' +
the name + '>', and process it to produce an element with the relevant
content.  The problem is that if you have nested pseudo-elements with the
same name then you need something so much more sophisticated that it is
nigh-on impossible.

I feel that offering any more assistance than that would be like
encouraging you to go down a road that I know ends in a cliff.  You should
not be writing an XML parser in XSLT.  It's an interesting theoretical
challenge, but it's just completely unnecessary.

Sorry,

Jeni


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords