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 17th, 2003, 12:52 AM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML Transformation Trouble...

Hi all,
Currently I am working on a template solution which transforms contents of a given section (which is in a xml format) with the help of preset XLST files assigned to those sections. The code goes something like this

/Default.aspx

.
.
.
.
// Get the sections data in XML format
string xmlData = DataLoader.GetSectionData(sectionName, sectionPath, articleId, pageNumber );

// Get that sections template file
string xslFile = Server.MapPath("/")+"Files\\Templates\\"+ templateFile +"\\Default.xsl";

System.IO.StringReader sr = new System.IO.StringReader(xmlData);

XPathDocument doc = new XPathDocument(sr);

XslTransform trans = new XslTransform();

trans.Load(xslFile);

//Transform it and output as HTML
XmlTextWriter writer = new XmlTextWriter(Response.Output);

writer.Formatting = Formatting.None;

trans.Transform(doc,null,writer);



/SectionData.xml
<Root>
<Article>
<Title>Wonders of life</Title>
<Content>
<!--
[u]Sometimes[u], you wonder how a particular thing went wrong; < b>but most of the time</ b> you wonder how it worked at all
-->
</Content>
</Article></Root>


/SectionTemplate.xslt
.
.
.
<xsl:value-of select="/Root/Article/Title" />
<br />
<xsl:value-of select="/Root/Article/Content/comment()" disable-output-escaping="yes" />
.
.
.




What i expected of the tranformer was to spit the contents of the comment tag to the browser without any parsing/escaping so the html formatting of the given article can be maintained, but whatever is done (I even tried with copy-of xsl element to no effect) the output I get is like this in the article page (HTML VIEW of the generated code)

Wonders of life<br />
&lt;u&gt;Sometimes&lt;u&gt;, you wonder how a particular thing went wrong; &lt;b&gt;but most of the time&lt;/b&gt; you wonder how it worked at all


Any help would be appreciated, Thanking you

CreProDes
 
Old October 17th, 2003, 04:06 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

As far as I know comments are that, comments. Their content is not treated as xml, just text. Embedding html in comment tags is a poor way of structuring data to start with, do you have any control over this?

--

Joe
 
Old October 17th, 2003, 04:43 AM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The main reason iam using comment to put the data in is to make it to not treat like a html, this module is a part of an inhouse cms system and the article module has client side wysiwyg editor. so the user will be providing an formatted html for the article and i want to maintain the html format when displaying the article in designated section.


I would like to get any alternate practise for accomplishing the same and would be thankful.


CreProDes





Similar Threads
Thread Thread Starter Forum Replies Last Post
xml transformation spring152103 XSLT 9 October 14th, 2008 07:50 PM
Is XML supports transformation of HTML to XML? zeeonline XSLT 1 July 28th, 2006 05:13 PM
Problem in XML to XML transformation jkuravatti XSLT 2 May 5th, 2006 11:21 AM
Xml to Xml Transformation using xslt ShaileshShinde XSLT 1 July 20th, 2005 01:20 AM
XML to XML transformation using XSLT karjagis XSLT 3 July 30th, 2004 06:13 AM





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