Ok, I feel like this is a really stupid question, but I’ve been trying for some time to get it so my XSLT file will spit out the output encapsulated in some arbitrary element, let’s call it “root”. How would I achieve this?
Here is my current XSLT if that helps at all:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="DCField">
<xsl:choose>
<xsl:when test="@FieldValueType='None'">
<xsl:element name="{Name}">
<xsl:value-of select="Value" />
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{@FieldValueType}">
<xsl:value-of select="Value" />
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
And I want it so my output looks like:
<root>
<element1>
<element2>
...
</root>
Just wrap the contents of your root-matching template in a
<root>tag.http://www.xmlplayground.com/RYv2XW (see output source)