Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: how to generate markups?

From: "Joe Fawcett" <joefawcett@---------.------>
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:



             &lt;B&gt;0&lt;B/&gt; 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





transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent