> This is a mistake be...">

XSLT output for HTML

In my XSLT file, I have the following:

<input type="button" value= <xsl:value-of select="name">>

This is a mistake because it violates the XML rule.

Actually, I want to have the value from the XML file assigned to the value parameter in the HTML output. How can I do it? Thanks

+3
source share
5 answers

It does not need to be used at all xsl:element; I don’t know why so many people offer it. This will work:

<input type="button">
   <xsl:attribute name="value">
      <xsl:value-of name="name"/>
   </xsl:attribute>
</input>

... but even better uses an attribute value pattern:

<input type="button" value="{name}"/>
+5
source
<xsl:element name="input">
<xsl:attribute name="type">button</xsl:attribute>
<xsl:attribute name="value" select="name">
</xsl:element>

Great HTML / XSL Link

+6
source
value="{name}"

. http://www.w3.org/TR/xslt#attribute-value-templates

EDIT: {$ name} {name}

+5

-

<xsl:element name="a"><xsl:attribute name="href"><xsl:value-of select="url" /></xsl:attribute> <xsl:attribute name="target">_blank</xsl:attribute></xsl:element>

xsl: attribute

+3

Yes, use <xsl:element>is the way to go here, but you got your parsing error because you did not close the element <xsl:value-of select="name" />. Pay attention to /the end; all XML elements need to be closed, unlike HTML.

+1
source

Source: https://habr.com/ru/post/1722763/


All Articles