|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
xsl:element versus using the element itself
I was reading up on RSS, and in the example they gave, the XSL had a line like this:
Code:
<xsl:element name="a">
<xsl:attribute name="href">
etcetera
Well, why wouldn't I just type <a href="{url}" instead?
__________________
Hello, old friend... |
|
#2
|
||||
|
||||
|
I personally use this too, I think its just a neater way of seperating out the attributes, its really useful when you want to use XML data within the attribute. If you do it the way you suggest you end up with one really long line.
|
|
#3
|
||||
|
||||
|
I only use the xsl:element when having to create element names are that are dynamic. You can also use xsl:element to assign computed namespaces to the element. This also applies to xsl:attribute.
Code:
<xsl:element name="{$someVariable}" namespace="{$computedNamespace}">
Some text
</xsl:element>
|
|
#4
|
||||
|
||||
|
Quote:
Since the xsl:element is only created in the result tree, what is a practical application of having dynamic elements? |
|
#5
|
|||
|
|||
|
Using the xsl:attribute element is better for a number of reasons including the fact the your code is easier to
understand and parse. Also some processors have useful extensions, for example: <xsl:attribute name="fpm" saxon:disable-output-escaping="yes"> <xsl:value-of select="."/> </xsl:attribute> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > xsl:element versus using the element itself |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|