473,237 Members | 1,250 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

Sending XML Content (with < >) as value of an attributes to Object tag in HTML

Hi,

What I am trying to do:
=======================

I need to form a table in html using the xsl but the table that is
formed is quite long and cannot be viewed in our application. So we
are writing one object in C# which will take the entire table tag
contents and renders. Ie., we need to pass "<table>…………
<thead>……</thead>. <tr>.<td> <td>..<tr>.<td> <td> </table>" content to
the object using Object tag.

So I have written the xsl as

<object classid="………..">
<xsl:attribute name="HTMLContent">
<xsl:apply-templates select="tgroup"/>
</xsl:attribute>
</object>

Here the HTMLContent is an attribute of the object which will be
interpreted by the C# objeect class aptly. "tgroup" template would
give the entire table content ( "<table>………… <thead>……</thead>.
<tr>.<td> <td>..<tr>.<td> <td> </table>" ).

This XSL should be transformed as

<object classid="……." HTMLContent="<table>………… <thead>……</thead>.
<tr>.<td> <td>..<tr>.<td> <td> </table>">

But the table tag value is going as blank to the HTMLContent
attribute.
i.e,

<object classid="……." HTMLContent="">

But if I give some thing like

<object classid="………..">
<xsl:attribute name="HTMLContent">
Sample
</xsl:attribute>
</object>

The XSL transforms as

<object classid="……." HTMLContent="Sample">
</object>

I really don't understand why the table content is not getting in to
the HTMLContent attribute of Object tag. Is there a way where I can do
like this.

I am struck up in this for a long time. Please help me out.

Thanks and Regards,
-Eshrath.
Jul 20 '05 #1
2 3163
Hi,

Not sure trying to put markup inside an attribute is ever the best idea?
I've never used the <object> much - are you sure you can't put the markup as
the content in some way (maybe namespaced?).

But anyway, to put markup into an attribute using XSL you will need to do
your own escaping of the tags, e.g.

== XML ==============================
<?xml version="1.0"?>
<tgroup>
<table border="1">
<!-- comment -->
<?pi something?>
<thead>hd</thead>
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
</table>
</tgroup>
== end of XML =======================

== XSL ==============================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<object classid=".....">
<xsl:attribute name="HTMLContent">
<xsl:apply-templates select="tgroup" mode="esc-start"/>
</xsl:attribute>
</object>
</body>
</html>
</xsl:template>

<xsl:template match="*" mode="esc-start">
<xsl:apply-templates mode="esced"/>
</xsl:template>

<xsl:template match="*" mode="esced">
<xsl:text>&lt;</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*" mode="esced"/>
<xsl:text>&gt;</xsl:text>
<xsl:apply-templates mode="esced"/>
<xsl:text>&lt/;</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>&gt;</xsl:text>
</xsl:template>

<xsl:template match="@*" mode="esced">
<xsl:text> </xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"</xsl:text>
</xsl:template>

<xsl:template match="comment()" mode="esced">
<xsl:text>&lt;!--</xsl:text>
<xsl:value-of select="."/>
<xsl:text>--&gt;</xsl:text>
</xsl:template>

<xsl:template match="processing-instruction()" mode="esced">
<xsl:text>&lt;?</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text> </xsl:text>
<xsl:value-of select="."/>
<xsl:text>?&gt;</xsl:text>
</xsl:template>

</xsl:stylesheet>
== end of XSL =======================

You could etend this further with a template (in mode "esced") that looked
for HTML tags that didn't require closing properly (i.e. <br>, <hr>, etc.),
e.g. adding the template...

<xsl:template match="*[contains('|br|hr|',concat('|',
translate(name(),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz'),'|'))]" mode="esced">
<xsl:choose>
<xsl:when test="node()">
<xsl:text>&lt;</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*" mode="esced"/>
<xsl:text>&gt;</xsl:text>
<xsl:apply-templates mode="esced"/>
<xsl:text>&lt;/</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>&gt;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>&lt;</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*" mode="esced"/>
<xsl:text>&gt;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
HTH
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Eshrath" <es*****@gmail.com> wrote in message
news:4f*************************@posting.google.co m...
Hi,

What I am trying to do:
=======================

I need to form a table in html using the xsl but the table that is
formed is quite long and cannot be viewed in our application. So we
are writing one object in C# which will take the entire table tag
contents and renders. Ie., we need to pass "<table>....
<thead>..</thead>. <tr>.<td> <td>..<tr>.<td> <td> </table>" content to
the object using Object tag.

So I have written the xsl as

<object classid=".....">
<xsl:attribute name="HTMLContent">
<xsl:apply-templates select="tgroup"/>
</xsl:attribute>
</object>

Here the HTMLContent is an attribute of the object which will be
interpreted by the C# objeect class aptly. "tgroup" template would
give the entire table content ( "<table>.... <thead>..</thead>.
<tr>.<td> <td>..<tr>.<td> <td> </table>" ).

This XSL should be transformed as

<object classid="..." HTMLContent="<table>.... <thead>..</thead>.
<tr>.<td> <td>..<tr>.<td> <td> </table>">

But the table tag value is going as blank to the HTMLContent
attribute.
i.e,

<object classid="..." HTMLContent="">

But if I give some thing like

<object classid=".....">
<xsl:attribute name="HTMLContent">
Sample
</xsl:attribute>
</object>

The XSL transforms as

<object classid="..." HTMLContent="Sample">
</object>

I really don't understand why the table content is not getting in to
the HTMLContent attribute of Object tag. Is there a way where I can do
like this.

I am struck up in this for a long time. Please help me out.

Thanks and Regards,
-Eshrath.

Jul 20 '05 #2
Hi,

Not sure trying to put markup inside an attribute is ever the best idea?
I've never used the <object> much - are you sure you can't put the markup as
the content in some way (maybe namespaced?).

But anyway, to put markup into an attribute using XSL you will need to do
your own escaping of the tags, e.g.

== XML ==============================
<?xml version="1.0"?>
<tgroup>
<table border="1">
<!-- comment -->
<?pi something?>
<thead>hd</thead>
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
</table>
</tgroup>
== end of XML =======================

== XSL ==============================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<object classid=".....">
<xsl:attribute name="HTMLContent">
<xsl:apply-templates select="tgroup" mode="esc-start"/>
</xsl:attribute>
</object>
</body>
</html>
</xsl:template>

<xsl:template match="*" mode="esc-start">
<xsl:apply-templates mode="esced"/>
</xsl:template>

<xsl:template match="*" mode="esced">
<xsl:text>&lt;</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*" mode="esced"/>
<xsl:text>&gt;</xsl:text>
<xsl:apply-templates mode="esced"/>
<xsl:text>&lt/;</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>&gt;</xsl:text>
</xsl:template>

<xsl:template match="@*" mode="esced">
<xsl:text> </xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>"</xsl:text>
</xsl:template>

<xsl:template match="comment()" mode="esced">
<xsl:text>&lt;!--</xsl:text>
<xsl:value-of select="."/>
<xsl:text>--&gt;</xsl:text>
</xsl:template>

<xsl:template match="processing-instruction()" mode="esced">
<xsl:text>&lt;?</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text> </xsl:text>
<xsl:value-of select="."/>
<xsl:text>?&gt;</xsl:text>
</xsl:template>

</xsl:stylesheet>
== end of XSL =======================

You could etend this further with a template (in mode "esced") that looked
for HTML tags that didn't require closing properly (i.e. <br>, <hr>, etc.),
e.g. adding the template...

<xsl:template match="*[contains('|br|hr|',concat('|',
translate(name(),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz'),'|'))]" mode="esced">
<xsl:choose>
<xsl:when test="node()">
<xsl:text>&lt;</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*" mode="esced"/>
<xsl:text>&gt;</xsl:text>
<xsl:apply-templates mode="esced"/>
<xsl:text>&lt;/</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>&gt;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>&lt;</xsl:text>
<xsl:value-of select="name()"/>
<xsl:apply-templates select="@*" mode="esced"/>
<xsl:text>&gt;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
HTH
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator

"Eshrath" <es*****@gmail.com> wrote in message
news:4f*************************@posting.google.co m...
Hi,

What I am trying to do:
=======================

I need to form a table in html using the xsl but the table that is
formed is quite long and cannot be viewed in our application. So we
are writing one object in C# which will take the entire table tag
contents and renders. Ie., we need to pass "<table>....
<thead>..</thead>. <tr>.<td> <td>..<tr>.<td> <td> </table>" content to
the object using Object tag.

So I have written the xsl as

<object classid=".....">
<xsl:attribute name="HTMLContent">
<xsl:apply-templates select="tgroup"/>
</xsl:attribute>
</object>

Here the HTMLContent is an attribute of the object which will be
interpreted by the C# objeect class aptly. "tgroup" template would
give the entire table content ( "<table>.... <thead>..</thead>.
<tr>.<td> <td>..<tr>.<td> <td> </table>" ).

This XSL should be transformed as

<object classid="..." HTMLContent="<table>.... <thead>..</thead>.
<tr>.<td> <td>..<tr>.<td> <td> </table>">

But the table tag value is going as blank to the HTMLContent
attribute.
i.e,

<object classid="..." HTMLContent="">

But if I give some thing like

<object classid=".....">
<xsl:attribute name="HTMLContent">
Sample
</xsl:attribute>
</object>

The XSL transforms as

<object classid="..." HTMLContent="Sample">
</object>

I really don't understand why the table content is not getting in to
the HTMLContent attribute of Object tag. Is there a way where I can do
like this.

I am struck up in this for a long time. Please help me out.

Thanks and Regards,
-Eshrath.

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: dpj5754 | last post by:
Is there a simple and determinist way to make the difference between the 2 sequences: <XX></XX> and <XX/> The EndElement callback does not provide this information.
3
by: Lars G. Svensson | last post by:
Currently, I'm marking up a few pages in German, containing quite some English abbreviations. The abbreviations are marked up as <abbr> with the appropriate title attribute, and -- when appropriate...
14
by: laurence | last post by:
I am implementing a comprehensive image-map generator utility, so have been studying W3C HTML 4.01 Specification (http://www.w3.org/TR/html4/struct/objects.html#h-13.6) on image maps (among other...
2
by: Fredrik Melin | last post by:
Hi, I have a vendor that requires me to send empty value, e.g. <OrderIDInfo /> problem is that my xslt need to add attributes, doing this <OrderIDInfo> <xsl:attribute name="orderID">...
1
by: Aaron | last post by:
Hello, I want to transform html tags with in the xml file when it use the asp:xml tag, how would I do this? Here is the example of the xslt file: <?xml version="1.0" ?> <xsl:stylesheet...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
7
by: Nathan Sokalski | last post by:
Something that I recently noticed in IE6 (I don't know whether it is true for other browsers or versions of IE) is that it renders <br/and <br></br> differently. With the <br/version, which is what...
4
by: mark4asp | last post by:
I have an element, report which contains tags which have been transformed. E.g. <pis &lt;p&gt <myXml> <report>This text has html tags in it.&lt;p&gt which but <has been changed to &lt;&gt</report>...
10
by: lpinho | last post by:
Hi all, I have a class (named for the example myObject) that can be of several types (int, string, float, etc), instead of using a object to define it's type I used a generic. public class...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.