Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 16th, 2007, 12:44 PM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to carlosaml
Default Convert entities...

Hi all

I have an element called <attributes> that has a XML inside, generated by a .NET Dataset (the content is like "&lt;attribute name="test"&gt;My Content&lt;/attribute&gt;" 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;

Reply With Quote
  #2 (permalink)  
Old October 16th, 2007, 12:50 PM
mhkay's Avatar
Wrox Author
Points: 17,773, Level: 58
Points: 17,773, Level: 58 Points: 17,773, Level: 58 Points: 17,773, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,839
Thanks: 0
Thanked 267 Times in 262 Posts
Default

When you first parse your XML, the &lt; 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
Reply With Quote
  #3 (permalink)  
Old October 16th, 2007, 01:00 PM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to carlosaml
Default

Quote:
quote:Originally posted by mhkay
 When you first parse your XML, the &lt; 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.

Reply With Quote
  #4 (permalink)  
Old October 16th, 2007, 01:08 PM
joefawcett's Avatar
Wrox Author
Points: 9,731, Level: 42
Points: 9,731, Level: 42 Points: 9,731, Level: 42 Points: 9,731, Level: 42
Activity: 8%
Activity: 8% Activity: 8% Activity: 8%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,068
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)
Reply With Quote
  #5 (permalink)  
Old October 16th, 2007, 01:11 PM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to carlosaml
Default

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

Reply With Quote
  #6 (permalink)  
Old October 16th, 2007, 01:19 PM
joefawcett's Avatar
Wrox Author
Points: 9,731, Level: 42
Points: 9,731, Level: 42 Points: 9,731, Level: 42 Points: 9,731, Level: 42
Activity: 8%
Activity: 8% Activity: 8% Activity: 8%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,068
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you can convert it to an XML datatype then I think you can. Can you change the underlying query?

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #7 (permalink)  
Old October 16th, 2007, 01:24 PM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to carlosaml
Default

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

Reply With Quote
  #8 (permalink)  
Old October 16th, 2007, 01:37 PM
joefawcett's Avatar
Wrox Author
Points: 9,731, Level: 42
Points: 9,731, Level: 42 Points: 9,731, Level: 42 Points: 9,731, Level: 42
Activity: 8%
Activity: 8% Activity: 8% Activity: 8%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,068
Thanks: 1
Thanked 38 Times in 37 Posts
Default

In that case you may be out of luck, I was hoping for SQL Server 2005. I will investigate.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #9 (permalink)  
Old October 16th, 2007, 01:56 PM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to carlosaml
Default

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

Reply With Quote
  #10 (permalink)  
Old October 16th, 2007, 02:07 PM
mhkay's Avatar
Wrox Author
Points: 17,773, Level: 58
Points: 17,773, Level: 58 Points: 17,773, Level: 58 Points: 17,773, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,839
Thanks: 0
Thanked 267 Times in 262 Posts
Default

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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 12:04 PM
referenced entities bcogney XSLT 0 April 20th, 2006 03:37 PM
Entities as String muki XSLT 3 November 12th, 2005 12:15 PM
Entities safin XSLT 1 November 7th, 2005 04:59 AM



All times are GMT -4. The time now is 08:59 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.