473,416 Members | 1,746 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,416 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 3174
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.