|
 |
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 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 .
|
 |
|
|
 |
|

October 16th, 2007, 11:44 AM
|
Authorized User
|
|
Join Date: Jul 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Convert entities...
Hi all
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??
Thx;
|

October 16th, 2007, 11:50 AM
|
 |
Wrox Author
Points: 18,487, Level: 59 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|

October 16th, 2007, 12:00 PM
|
Authorized User
|
|
Join Date: Jul 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
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.
|

October 16th, 2007, 12:08 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
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?
--
Joe ( Microsoft MVP - XML)
|

October 16th, 2007, 12:11 PM
|
Authorized User
|
|
Join Date: Jul 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
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?
--
Joe (Microsoft MVP - XML)
|
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?
Thanks
|

October 16th, 2007, 12:19 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
If you can convert it to an XML datatype then I think you can. Can you change the underlying query?
--
Joe ( Microsoft MVP - XML)
|

October 16th, 2007, 12:24 PM
|
Authorized User
|
|
Join Date: Jul 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by joefawcett
If you can convert it to an XML datatype then I think you can. Can you change the underlying query?
--
Joe (Microsoft MVP - XML)
|
Change the type of the Dataset field or in the database?
I can change in either one (using .NET 1.1 and SQL Server 2k).
|

October 16th, 2007, 12:37 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
In that case you may be out of luck, I was hoping for SQL Server 2005. I will investigate.
--
Joe ( Microsoft MVP - XML)
|

October 16th, 2007, 12:56 PM
|
Authorized User
|
|
Join Date: Jul 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by joefawcett
In that case you may be out of luck, I was hoping for SQL Server 2005. I will investigate.
--
Joe (Microsoft MVP - XML)
|
Hmmm.. Thanks.. I appreciate that..
In the meanwhile... Anyone knows how to convert the entities to the actual symbols via xslt?
thankls
|

October 16th, 2007, 01:07 PM
|
 |
Wrox Author
Points: 18,487, Level: 59 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |