Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 16th, 2007, 01:14 PM
Authorized User
 
Join Date: Jul 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to carlosaml
Default

Quote:
quote:Originally posted by mhkay
 If you're using MSXML, then you can write Javascript code in an <msxsl:script> block which you can invoke from an XPath expression during the course of the transformation (look up "extension functions"). This Javascript code can invoke the MSXML parser on your escaped string and pass back the resulting DOM tree.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
I'm using .NET 1.1...
Does it uses MSXML or has its own implementation?

 
Old October 16th, 2007, 01:29 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you're using System.Xml.Xsl in .NET then there's some material on writing extension functions at

http://msdn2.microsoft.com/en-us/library/system.xml.xsl.xsltransform(vs.71).aspx

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 17th, 2007, 03:52 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I've not played around with this stuff in .Net yet so I was curious so I knocked together the following sample:

XML File to be processed:
Code:
<?xml version="1.0" encoding="utf-8" ?> 
<root>
    <child>
    &lt;element att="value"&gt;one&lt;/element&gt;
    </child>
</root>
XSL Transform File:
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
    xmlns:my="http://www.wackylabs.net/dotnet" 
    exclude-result-prefixes="my msxsl">

<xsl:output indent="yes" />

<msxsl:script implements-prefix='my' language='C#'>
  <![CDATA[
  public XPathNavigator ParseXml(string xml)
  {
    System.IO.StringReader sr = new System.IO.StringReader(xml);
    XPathDocument doc = new XPathDocument(sr);
    return doc.CreateNavigator();
  }
  ]]>
</msxsl:script>
<xsl:template match="child">
    <child>
        <xsl:copy-of select="my:ParseXml(string(.))" />
    </child>
</xsl:template>

</xsl:stylesheet>
The output, after running through XslTransform:
Code:
<?xml version="1.0" encoding="utf-8"?>
<child>
  <element att="value">text here</element>
</child>
I hope this gives you a good starting point for your own code.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Character to Unicode entities Pankaj C XSLT 2 February 15th, 2008 08:59 AM
referenced entities bcogney XML 7 April 21st, 2006 11:04 AM
referenced entities bcogney XSLT 0 April 20th, 2006 02:37 PM
Entities as String muki XSLT 3 November 12th, 2005 12:15 PM
Entities safin XSLT 1 November 7th, 2005 04:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.