XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Steve NicolsonSubject: Rendering HTML inside XML through XSL - HELP !!!
Author: Steve Nicolson
Date: 23 May 2007 01:15 AM
Originally Posted: 23 May 2007 01:10 AM
Hello everyone ! This is my first post and its very urgent for me :) hope you guys will help me out here.

I have this xml in which I have html tags. I want to render the "<myhtml>" (as in example below) tag through my XSL while retaining its formatting. At the moment my xsl (<xsl:value-of select="/top/myhtml"/>) is rendering <myhtml> tag's inner content as it is without taking care of any formatting tags

e.g.

<top>
<myhtml>
Some <b>bold</b> content and some <i>italic</i> content
</myhtml>
</top>

Thanks in advance.

Postnext
Elias HuterSubject: Rendering HTML inside XML through XSL - HELP !!!
Author: Elias Huter
Date: 23 May 2007 03:27 AM
Ok I'm not 100 % sure what you want, but as its urgent I'll throw in some thnings that come to my mind and hope other users can help better:

Here is a template which copies your whole source XML (also the formatting tags) and still allows you to make modifications:

Heres a template of how to do it:

<xsl:template match="/">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="copy"/>
</xsl:copy>
</xsl:template>

<xsl:template match="@*|node()" mode="copy">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="copy"/>
</xsl:copy>
</xsl:template>

If you simply want a 1on1 copy you can use xsl:copy-of

Also be sure you chose "html" in the Params/Other tab if you want html as output.

Regards

Postnext
Steve NicolsonSubject: Rendering HTML inside XML through XSL - HELP !!!
Author: Steve Nicolson
Date: 23 May 2007 05:49 AM
Originally Posted: 23 May 2007 05:41 AM
Thanks Elias, for your quick response!

Just to further illustrate my point..:

<?xml version='1.0'?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes" >
.. .. ..
.. .. ..
<xsl:for-each select="/top" order-by="id">
<tr>

<!-- asuming that the node <id /> exists at same level besides myhtml - had it hidden before for simplicity -->

<td><xsl:value-of select="id"/></td>
<td><xsl:value-of select="myhtml"/></td>

</tr>
.. .. ..

Using <xsl:copy-of> in place of <xsl:value-of> as per suggestion generated the following error


Keyword xsl:copy-of may not be used in namespace http://www.w3.org/TR/WD-xsl. I had been using this namespace specifically to get the sort operation work ("order-by='id'").

Postnext
Elias HuterSubject: Rendering HTML inside XML through XSL - HELP !!!
Author: Elias Huter
Date: 23 May 2007 06:15 AM
I suggest you use:

<xsl:for-each select="top">
<xsl:sort select="id"/>

instead of:

<xsl:for-each select="/top" order-by="id">

As for your Problem that you only get the text:

xsl:value-of doenst give you back the attributes and childs so you have to use xsl:copy and use it recursive to be sure you get the childs of the childs and so on.

Find an example attached.


Documentmyhtml_example.xml
Example XML

Documentmyhtml.xsl
XSL solution

Postnext
Elias HuterSubject: Rendering HTML inside XML through XSL - HELP !!!
Author: Elias Huter
Date: 23 May 2007 07:15 AM
Originally Posted: 23 May 2007 06:42 AM
I just recognized that I don't exchange the "myhtml" tag with the "td" tag. So find a new, final solution attached.

(I didn't delete the old XSLT in the former post, so you can learn how this problem was solved)


Documentmyhtml_new(1).xsl

Postnext
Steve NicolsonSubject: Rendering HTML inside XML through XSL - HELP !!!
Author: Steve Nicolson
Date: 23 May 2007 09:42 AM
Originally Posted: 23 May 2007 09:41 AM
@Elias..
>Ok I'm not 100 % sure what you
>want, . . .

Now you are.. and this is 100 % what I was trying to do! Thanks - you have been great help!

Err.. since i am new into this xslt thingy, 1 thing I'd like to ask you in the context of my Q (without hijacking my post ;)).. So far i havent been using any xml tool for the task, what tool you think (without being biased :D) would suit me for this kind of development since I'd now be into a lot of 'node processing' (searching by date/time, e.g.) after getting through this rather basic thing.

btw. i noticed you had been using Stylus!

Postnext
Elias HuterSubject: Rendering HTML inside XML through XSL - HELP !!!
Author: Elias Huter
Date: 23 May 2007 10:40 AM
Originally Posted: 23 May 2007 10:39 AM
I'm not really into this topic but I can tell you what where the two things why we deceided for Stylus Studio:

- A really big company suggested it to us as XSLT/XML tool which fits best for our needs (Mainly Mappings from one format to another e.g. IDOC to EDIFACT) and they also used it by themselves
- The biggest advantage was that you can change the parser, to whatever you want. As we use SAP-XI we can use the XI Parser which is very important, as for example Saxon would accept "something" but the XI-Parser rejects the same thing (and the other way round). That would result in an "OK" in your development tool (with lets say Saxon parser) but an error after deploying it (SAP-XI parser)

So far I can say that for those things we are doing with it, Stylus Studio is a very good tool with fast developer feedback as a plus.

I suggest you download a few tools, they all offer trial versions, and find the tool which fits for you best! The only other tool I know is XML Spy which also seems to be pretty popular.

Postnext
Steve NicolsonSubject: Rendering HTML inside XML through XSL - HELP !!!
Author: Steve Nicolson
Date: 23 May 2007 11:11 AM
Originally Posted: 23 May 2007 10:57 AM
Just a little thing which is causing inability to display my node containing inside html tags.. please if you could figure it out for me.. Elias


UnknownView.xml
View.xml

UnknownView.xsl
View.xsl

Postnext
Elias HuterSubject: Rendering HTML inside XML through XSL - HELP !!!
Author: Elias Huter
Date: 23 May 2007 11:24 AM
Originally Posted: 23 May 2007 11:18 AM
Be sure you use the technique in my last post -> myhtml_new(1).xsl otherwise you will get a <comment> tag within your <td> tag because the comment tag is also copied.

That would be:

<td>
<xsl:for-each select="comment">
<xsl:apply-templates mode="copy"/>
</xsl:for-each>
</td>

instead of:

<td>
<xsl:for-each select="comment">
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates mode="copy" />
</xsl:copy>
</xsl:for-each>
</td>

Maybe thats the source of the error.

Update:
Very unlucky -> it seems as if Internet Explorer interprets <comment> tags and just skips everything inside. Would the tagname have been for example <freetext> you would have gotten an output anyway.

Posttop
Steve NicolsonSubject: Rendering HTML inside XML through XSL - HELP !!!
Author: Steve Nicolson
Date: 23 May 2007 11:33 AM
Oh yes.. haste makes waste! I am using the new xsl and its working fine now :) Thanks!

Best regards

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.