For example, XML:
<Root> <item> abcdefabcdeabcdef </item> </root> needs to write XSL to convert the XML. All B in the content of item in the output must be changed to B, and normal XSL cannot be completed.
How to embed Javascript:XSL: <? XML version = "1.0" encoding = "gb2312"?>
<XSL: stylesheet version = "1.0" xmlns: XSL = "http://www.w3.org/1999/XSL/Transform"Xmlns: msxsl = "urn: Schemas-Microsoft-com: XSLT"
Xmlns: myns = "urn: mynamespace">
<Msxsl: script language = "jscript" implements-Prefix = "myns">
<! [CDATA [
Function trans (s)
{
VaR ary = S. Split ('B ');
Return ary. Join ('B ');
}
]>
</Msxsl: SCRIPT><XSL: template match = "/">
<XSL: Apply-templates select = "// root/item"/>
</XSL: Template> <XSL: template match = "root/item">
<XSL: value-of select ="Myns: Trans (string (.))"/>
</XSL: Template>
</XSL: stylesheet>
What do you think?
The script can be C # Instead of JScript #:
<Msxsl: script language = "C #" implements-Prefix = "myns">
<! [CDATA [
Public String trans (string S)
{
String [] ary = S. Split ('B ');
Return string. Join ('B', Ary );
}
]>
</Msxsl: SCRIPT> but it can only be parsed using system. xml of. NET Framework, rather than MSXML commonly used by clients.
Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 130529