1

I want to output an XML File. In this XML File there is a tag with attribute-content inside quotation marks. How do i have to alter the XSL-Stylesheet to accomplish this?

I didn't find any other entry here that solves this problem. How do I create the quotation marks before and after the xsl:value-of?

<xsl:for-each select="INPUTDOC/STRUCTURE">
    <xmlelement attribute="<xsl:value-of select="INPUT"/>"/>
</xsl:for-each>

XML-Output should look like this (For every STRUCTURE-Element)

<xmlelement attribute="123456"/>

123456 being an example Input

rialisuw
  • 27
  • 1
  • 6

1 Answers1

0

That is not how you would use the value-of, or how to define an attribute on an element using xslt. Try the following:

<xsl:for-each select="INPUTDOC/STRUCTURE">
    <xmlelement>
       <xsl:attribute name="[attributename]">
           <xsl:value-of select="INPUT"/>
       </xsl:attribute>
    </xmlelement>
</xsl:for-each>

Another and probably easier option is to use an attribute value template, as mentioned by Tim C in the comments. That way your code would look like this:

<xsl:for-each select="INPUTDOC/STRUCTURE">
    <xmlelement attribute="{INTPUT}"/>
</xsl:for-each>
ophychius
  • 2,623
  • 2
  • 27
  • 49