XSLTGeneral 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I have an element called <attributes> that has a XML inside, generated by a .NET Dataset (the content is like "<attribute name="test">My Content</attribute>" and so on)... I need to make a template in order to make the content a part of the XML itself, converting the entities to real "<" and ">".. How can I do this??
When you first parse your XML, the < will be turned into <. So the string value of the <attributes> element is a piece of unparsed XML. To turn it into XML that you can process, you need to parse it (that is, to parse it again). Typically this involves invoking the XML parser using an extension function. In Saxon this is built-in (saxon:parse()). In other environments you may be able to write your own.
Michael Kay http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
quote:Originally posted by mhkay
When you first parse your XML, the < will be turned into <. So the string value of the <attributes> element is a piece of unparsed XML. To turn it into XML that you can process, you need to parse it (that is, to parse it again). Typically this involves invoking the XML parser using an extension function. In Saxon this is built-in (saxon:parse()). In other environments you may be able to write your own.
Michael Kay http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Do you have any idea or example of how can I do this?
I'll create a template for doing just that...
Thanks.
quote:Originally posted by joefawcett
I would also suggest that the DataSet or the original data source is mis-configured if it is escaping the markup. Do you have any control over it?
The type of my field is xs:string, but it always escapethe characters... I've searched about it and found no way to make the Dataset not to escape entities... Is it possible to make the Dataset generate a unescaped output?
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