Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - how to generate markups? [Thread Next] Re: how to generate markups?To: NULL Date: 1/4/2006 3:27:00 PM "Dmitry Nogin" <dmitrynogin@h...> wrote in message
news:ex2Z2xTEGHA.2724@T......
Hi,
How to generate this sequence:
<B>0</B> minutes
instead of:
<B>0<B/> minutes
in the following situation:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl=http://www.w3.org/1999/XSL/Transform
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:vb="xxx.xxx.xxx">
<xsl:output method="html"/>
<msxsl:script language="VBScript" implements-prefix="vb">
<![CDATA[
;my vbscript function returns formatted html output
Function formatDuration()
formatDuration = "<B>0</B>
minutes"
End Function
]]>
</msxsl:script>
<!-- what should I do here ? -->
<xsl:template match="/">
<xsl:value-of select="vb:formatDuration()"/>
</xsl:template>
</xsl:stylesheet>
thank you
Not sure why you want to do this with a script extension as it seems easy
enough with standard XSLT but there are (at least) two methods.
Firstly, and not recommended as it's not guaranteed to work in all
situations (but neither is using VBscript extensions), is to use
disable-output-escaping:
<xsl:value-of disable-output-escaping="yes" select="vb:formatDuration()"/>
It's a real hack and I only mention it to pre-empt someone else saying it
without the warnings.
A better way would be to construct an element using an instance of
msxml2.domdocument.4.0 (or whatever the highest version is that will be
available) and return it from the function, then use:
<xsl:copy-of select="vb:formatDuration()/node()" />
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:vb="http://joe.fawcett.name/vbscript"
exclude-result-prefixes="vb msxsl">
<xsl:output method="html" />
<msxsl:script language="VBScript" implements-prefix="vb">
<![CDATA[
Function formatDuration()
Dim oDoc
Set oDoc = CreateObject("msxml2.domdocument.4.0")
oDoc.loadXML "<data><B>0</B> minutes</data>"
Set formatDuration = oDoc.documentElement
End Function
]]>
</msxsl:script>
<xsl:template match="/">
<root>
<xsl:copy-of select="vb:formatDuration()/node()" />
</root>
</xsl:template>
</xsl:stylesheet>
--
Joe Fawcett (MVP - XML)
https://mvp.support.microsoft.com/profile=8AA9D5F5-E1C2-44C7-BCE8-8741D22D17A5
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
