Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: how to generate markups?

From: "Joe Fawcett" <joefawcett@---------.------>
To: NULL
Date: 1/4/2006 3:33:00 PM
"Martin Honnen" <mahotrash@y...> wrote in message 
news:uiDQINUEGHA.2728@T......
>
>
> Dmitry Nogin wrote:
>
>
>> 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>
>
> 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/

Not quite identical answers but pretty close Martin :)

-- 

Joe 




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