|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
xsl: it prints without any command
Hi,
i am pretty new to xsl and i ran into this weird problem. To me it's so weird it's even hard to describe. The xsl file prints the value of the following 2 xml nodes without any command. <superuser>TRUE</superuser> <admin>TRUE</admin> The page prints TRUETRUE and then follows the rest of the html and i havent got a clue why it prints those 2 values. This is xml and this is the xsl Thanks, Sarnix |
|
#2
|
||||
|
||||
|
I don't really have an explanation why, but this is what you need to do:
add the following template: Code:
<xsl:template match="/"> <xsl:apply-templates select="document/ftpuser"/> </xsl:template> and change the other template: Code:
<xsl:template match="ftpuser">
....
</xsl:template>
Last edited by MattSidesinger : February 26th, 2004 at 01:53 PM. |
|
#3
|
||||
|
||||
|
I think that if you don't match the XML document root (different than your document element) then the XSL uses a default template that matches textual element data and prints it out.
I will look at the spec and try to see if this is accurate. |
|
#4
|
|||
|
|||
|
while i agree that it's a good idea to start with a match of root (it just gives you more control) i'm pretty sure that xsl is not using a "default" template that will print the text of nodes out.
there has to be another, valid, reason as to why this is happening. |
|
#5
|
|||
|
|||
|
Here are the builtin (default) template rules for XSLT1. See section 5.8 of the specification for full details.
<xsl:template match="*|/"> <xsl:apply-templates> </xsl:template> <xsl:template match="@*|text()"> <xsl:value-of select="."> </xsl:template> <xsl:template match="comment()|processing-instruction()"/> Note the builtin template rule for copying text and attribute nodes. |
|
#6
|
||||
|
||||
|
Booyah! Thanks fpmurphy for the post ... I will now have babies with you.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > xsl: it prints without any command |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|