Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - XSLT code >Thread Next - Re: XSLT code Re: XSLT codeTo: NULL Date: 6/6/2008 3:13:00 PM
paul_0403@y... wrote:
> Can somebody show me how to insert values associated with a variable
> into the XML so the output will look like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <CentralServerRequest>
> <RequestInfo>
> <ResponseFile Mode="Overwrite">e:/tmp/response.xml</
> ResponseFile>
> <StatusFile>d:/tmp/status.xml</StatusFile>
> </RequestInfo>
> </CentralServerRequest>
Here is a sample stylesheet that uses the identity transformation
template and two templates to modify the ResponseFile and StatusFile
elements:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="response_file" select="'e:/tmp/response.xml'"/>
<xsl:param name="status_file" select="'d:/tmp/status.xml'"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ResponseFile[not(node())]">
<xsl:copy>
<xsl:value-of select="$response_file"/>
</xsl:copy>
</xsl:template>
<xsl:template match="StatusFile[not(node())]">
<xsl:copy>
<xsl:value-of select="$status_file"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
