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? Re: how to generate markups?To: NULL Date: 1/4/2006 4:27:00 PM Dmitry Nogin wrote: > 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> Consider simply writing an XSLT template that does the job for you but if you insist on using VBScript extension functions then you need to make sure you create nodes and not text, here is an example (watch for line wraps in the VBScript code) <?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="http://example.com/2006/vb1"> <xsl:output method="html"/> <msxsl:script language="VBScript" implements-prefix="vb"> <![CDATA[ Function FormatDuration (duration, msxmlVersion) Dim XmlDocument Set XmlDocument = CreateObject("Msxml2.DOMDocument." & msxmlVersion & ".0") XmlDocument.loadXML "<span><b>" & duration & "</b> minutes</span>" Set FormatDuration = XmlDocument.DocumentElement End Function ]]> </msxsl:script> <xsl:template match="/"> <html> <body> <xsl:copy-of select="vb:formatDuration(5, system-property('msxsl:version'))" /> </body> </html> </xsl:template> </xsl:stylesheet> Sample serialized HTML output would be <html xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:vb="http://example.com/2006/vb1"> <body><span><b>5</b> minutes</span></body> </html> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
