473,466 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

html tags inside xml elements

I am working on an xml project that will contain numerous documents
which will be edited by about 100-150 non-technical people on a
regular basis. Because of this, I am trying to make it as simple as
possible for them. This project is an internal project so it will only
ever be viewed on IE 6.x (or maybe 7.x if my company ever decides to
shoot itself in the foot) and because this is being deployed as a
replacement for a pre-existing structure, it will not be running on a
web-server either (they will be the xml files sitting on a shared
drive accessed by everyone.

I need a way to format text within elements that is as simple for the
person typing the xml data as possible (if the stylesheet is
complicated, that's ok I'm the only one that will be looking at that
and code doesn't scare me). The simplest coding method I've seen so
far to put in formatting is html tags, however xml does not properly
escape those. I only need the <b><u><itags to work. Does anyone have
any ideas for an xsl stylesheet that will properly display this
element?

<element><i>This</iis an <b>amazing</b<u>element</u>!!</element>

Mar 30 '07 #1
11 11563
* do******@gmail.com wrote in comp.text.xml:
>I need a way to format text within elements that is as simple for the
person typing the xml data as possible (if the stylesheet is
complicated, that's ok I'm the only one that will be looking at that
and code doesn't scare me). The simplest coding method I've seen so
far to put in formatting is html tags, however xml does not properly
escape those. I only need the <b><u><itags to work. Does anyone have
any ideas for an xsl stylesheet that will properly display this
element?

<element><i>This</iis an <b>amazing</b<u>element</u>!!</element>
I am not sure why escaping might be a problem here. Transforming the
above into HTML should be trivial, you just copy the elements into the
result (using xsl:copy, xsl:copy-of, or some other method).
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Mar 30 '07 #2
I am not sure why escaping might be a problem here. Transforming the
above into HTML should be trivial, you just copy the elements into the
result (using xsl:copy, xsl:copy-of, or some other method).
Exactly. If you want markup, use markup expressed in XML structure.
Personally I would prefer something more semantically meaningful than
fragments of XHTML (or concepts borrowed from XHTML), but XHTML would
have the advantage of being trivial to process and not requiring that
you educate the user about your own markup.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 30 '07 #3
On Mar 30, 9:31 am, Joseph Kesselman <keshlam-nos...@comcast.net>
wrote:
I am not sure why escaping might be a problem here. Transforming the
above into HTML should be trivial, you just copy the elements into the
result (using xsl:copy, xsl:copy-of, or some other method).

Exactly. If you want markup, use markup expressed in XML structure.
Personally I would prefer something more semantically meaningful than
fragments of XHTML (or concepts borrowed from XHTML), but XHTML would
have the advantage of being trivial to process and not requiring that
you educate the user about your own markup.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Ok, I think I see what I'm doing wrong. I've been using xsl:value-of
select! I just tested it with xsl:copy-of and that fixed it. Thank
you, I've spent the last 3 days tearing my hair out looking for an
answer that was right in front of me.

Mar 30 '07 #4
Ok, I'm not sure why, but suddenly that stopped working. All of my
xsl:copy-of selections quit making markup. Now, when I view my
documents, I get <b>this</b>, instead of formatted text. So, I poked
around and I found this transform which, when coupled with an
xsl:apply-templates command, should create the appropriate tags, but
it isn't working either. Here is the aforementioned code:

<xsl:template match="vendor">
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="b|i|u">
<xsl:element name="{name()}">
<xsl:apply-templates />
</xsl:element>
</xsl:template>

So what should happen is when it finds one with vendor, it should
apply templates, match all the <b>, <i>, and <utags, and create the
appropriate html tag. Instead, it is just passing them through as
text, so that I get this:

This vendor is <b>really</breliable.

Quick note on implimentation. The xml documents are stored on a shared
drive and accessed using Internet Explorer 6.0 (all computers in the
company have the same version of IE). The transforms are applied
dynamically using javascript calls in a shell html document. Currently
the code is being maintained in notepad and the office workers are
editing it in Word 2003, although plans are in the works to get a real
XML editor.

Apr 12 '07 #5
XSLT is namespace-sensitive. Check for namespaces, including a default
namespace declaration, in the source document.
Apr 12 '07 #6
On Apr 12, 6:00 pm, Joseph Kesselman <keshlam-nos...@comcast.net>
wrote:
XSLT is namespace-sensitive. Check for namespaces, including a default
namespace declaration, in the source document.
I tried it with and without namespace declarations in the xsl
document. Didn't seem to make a difference. The default namespace for
functions is supposed to be fn: but neither fn:name nor name produced
any results. Regardless of whether I declared the namespace or not.

Apr 14 '07 #7
On Apr 14, 4:55 am, "Doulos05" <doulo...@gmail.comwrote:
On Apr 12, 6:00 pm, Joseph Kesselman
<keshlam-nos...@comcast.netwrote:
XSLT is namespace-sensitive. Check for namespaces,
including a default namespace declaration, in the
source document.

I tried it with and without namespace declarations in the
xsl document. Didn't seem to make a difference. The
default namespace for functions is supposed to be fn: but
neither fn:name nor name produced any results. Regardless
of whether I declared the namespace or not.
Aw, shucks. I would like to help, but you see, my crystal
ball is malfunctioning at the moment.

(Does the phrase 'minimal complete example' ring any bells
with you?)

--
Pavel Lepin

Apr 14 '07 #8
Aw, shucks. I would like to help, but you see, my crystal
ball is malfunctioning at the moment.

(Does the phrase 'minimal complete example' ring any bells
with you?)

--
Pavel Lepin
My apologies, Pavel. I know a great crystal ball technician who may be
able to fix it for you, but in the interim I will copy the xml and xsl
documents. I was pressed for time when I posted the previous message
and did not have time to edit one of our account info documents to
remove the private information. Here is the XML document, named
"account info.xml" I stripped it down to the minimum necessary to
cause the problem:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="n:/Call Center Info/Call Center
All Accounts/Launchpad3_0/stylesheets/acctinfonormal.xsl"?>

<account>
<account_name>International Widget Factory</account_name>
<moddate>2007-04-11</moddate>
<greeting>Thank you for calling, this is _____ How may I help you?</
greeting>

<our_email>
<email>jo******@company.com</email>
<email_info><u>Do not give to customer.</uThis email is us to report
problems to Tier 2.</email_info>
</our_email>

<contacts>
<contact>
<contact_name>Terry</contact_name>
<contact_phone>123-456-7890</contact_phone>
<contact_email>te***@company.com</contact_email>
<contact_description>Our on-site representative</contact_description>
</contact>
</contacts>

<warehouse_contacts>
<contact>
<contact_name><b>M54: </bHeather</contact_name>
<contact_phone>123-451-1247</contact_phone>
<contact_email>he*****@company.com</contact_email>
<contact_description>Call for expediting, cancellation, etc.</
contact_description>
</contact>
</warehouse_contacts>

<buscard_contacts>
<contact>
<contact_name>Mike</contact_name>
<contact_phone>789-456-1470</contact_phone>
<contact_email>mi**@stationary.com</contact_email>
<contact_description><i>Do not give to customer.</iVendor has
requested that we not release this to the customer.</
contact_description>
</contact>
</buscard_contacts>

<rga>$40 restocking fee.</rga>

<miscs>
<misc>International Widget Factory occasionally requests foreign
deliveries. These are handled by Tier 2. Should you get a phone call
about a foreign delivery, contact Tier 2, they have the information.
The information <b>will not</bbe in the system because it cannot
handle international addresses.</misc>
</miscs>

</account>

Below is acctinfonormal.xsl:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<input type="button" value="Close this window" onclick="self.close()"/
>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match="account_name">
<h1><xsl:apply-templates/></h1>
</xsl:template>

<xsl:template match="moddate">
<h3><xsl:apply-templates/></h3>
</xsl:template>

<xsl:template match="greeting">
<p><b>Standard Greeting: </b><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="our_email">
<p><b>Standard Register Email: </b><a href="mailto:{/account/
our_email/email}"><xsl:value-of select="/account/our_email/email"/></
a- <xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="contacts">
<h2>Standard Register Contacts</h2>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="contact">
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="contact_name">
<b>Name: </b><xsl:apply-templates/><br />
</xsl:template>

<xsl:template match="contact_phone">
<b>Phone: </b><xsl:apply-templates/><br />
</xsl:template>

<xsl:template match="contact_email">
<b>Email: </b><a href="mailto:{.}"><xsl:value-of select="."/></a><br /
>
</xsl:template>

<xsl:template match="contact_description">
<b>Info: </b><xsl:apply-templates/>
</xsl:template>

<xsl:template match="warehouse_contacts">
<h2>Warehouse, POD, and Plant Contacts <span style="font-size:
12pt">(for order status, expediting, and canceling)</span></h2>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="buscard_contacts">
<h2>Business Card and Stationary Contacts:</h2>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="miscs">
<h2>Miscellaneous Information</h2>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="misc">
<p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="b|i|u">
<xsl:element name="{name()}">
<xsl:apply-templates />
</xsl:element>
</xsl:template>

</xsl:stylesheet>

This is my latest revision attempting to get the <b>, <u>, and <i>
tags to transform into html b,u, and i tags. Previously, I had used
<xsl:copy-of select="node_name"/and that was working fine until a
few days ago. Not sure what change caused the problems (this is a
fairly rapidly evolving project), but right now they are coming
through like so:

International Widget Factory occasionally requests foreign deliveries.
These are handled by Tier 2. Should you get a phone call about a
foreign delivery, contact Tier 2, they have the information. The
information <b>will not</bbe in the system because it cannot handle
international addresses.

Any assistance would be greatly appreciated. Thank you!
Apr 16 '07 #9

On Apr 16, 5:04 pm, "Doulos05" <doulo...@gmail.comwrote:
Aw, shucks. I would like to help, but you see, my
crystal ball is malfunctioning at the moment.
(Does the phrase 'minimal complete example' ring any
bells with you?)

This is my latest revision attempting to get the <b>,
<u>, and <itags to transform into html b,u, and i tags.
Previously, I had used <xsl:copy-of select="node_name"/>
and that was working fine until a few days ago. Not sure
what change caused the problems (this is a fairly rapidly
evolving project), but right now they are coming through
like so:
[looks like disable-output-escaping or something]

I'm unable to reproduce your problem in Firefox 2.0.0.3
using the sample documents provided. The transformation
result looks just peachy to me and renders just fine as
well. None of my stand-alone transformation processors
exhibited the behavior you seem to have described.

Either your XSLT processor is just a bit borken, or you
were tinkering with it and inadvertently broke it. I don't
see any other explanation at the moment.

--
Pavel Lepin

Apr 16 '07 #10
On Apr 16, 10:46 am, p.le...@ctncorp.com wrote:
[looks like disable-output-escaping or something]

I'm unable to reproduce your problem in Firefox 2.0.0.3
using the sample documents provided. The transformation
result looks just peachy to me and renders just fine as
well. None of my stand-alone transformation processors
exhibited the behavior you seem to have described.

Either your XSLT processor is just a bit borken, or you
were tinkering with it and inadvertently broke it. I don't
see any other explanation at the moment.

--
Pavel Lepin
Ok, thanks for the help. I'll look back over the code again, step
through it and see if I missed something when I snipped it down to fit
it more readily into the post. Also, is there any chance this could be
a "feature" of Internet Explorer's built-in XSLT processor? I know
I've heard that there were some portions of the old XSLT processor
that IE used that weren't W3C compliant, but I haven't seen whether or
not they fixed it. I've got Firefox at home as well, I'll send myself
the files and test it there to see if that's the case. I'll post what
I find when I get back from lunch.

Jonathan Bennett

Apr 16 '07 #11
On Apr 16, 7:20 pm, "Doulos05" <doulo...@gmail.comwrote:
On Apr 16, 10:46 am, p.le...@ctncorp.com wrote:
[looks like disable-output-escaping or something]
I'm unable to reproduce your problem in Firefox 2.0.0.3
using the sample documents provided. The transformation
result looks just peachy to me and renders just fine as
well. None of my stand-alone transformation processors
exhibited the behavior you seem to have described.
Either your XSLT processor is just a bit borken, or you
were tinkering with it and inadvertently broke it. I
don't see any other explanation at the moment.

Ok, thanks for the help. I'll look back over the code
again, step through it and see if I missed something when
I snipped it down to fit it more readily into the post.
Works just fine for me in IE6 as well. The problem is not
with your code, but with your XSLT processor and/or with
whatever you use to invoke the processor in question.
Also, is there any chance this could be a "feature" of
Internet Explorer's built-in XSLT processor?
It has little to do with IE per se, and everything to do
with MSXML. Anyway, I wouldn't put it past Microsoft to
break something and say it's better that way, but I
consider it unlikely in this case. You might want to try
upgrading your MSXML in either case. microsoft.public.xsl
probably has a more thriving population of experts on
MSXML's transformation engine and is ===that way.

--
Pavel Lepin

Apr 17 '07 #12

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

Similar topics

1
by: sindre hiåsen | last post by:
Hi, What I try to do is to search a text for html tags. Why. Because I want to use nl2br on the text, but since this command add br instead of all /n it is not a nice thing to add t.x. a html...
3
by: jjliu | last post by:
Could someone tell me how to parse the inside of html tags by perl, such as <meta> </meta> <head> </head> <title> </title> ......... Thanks
5
by: Donald Firesmith | last post by:
Are html tags allowed within meta tags? Specifically, if I have html tags within a <definition> tag within XML, can I use the definition as the content within the <meta content="description> tag? ...
2
by: hoz | last post by:
Hi , i have a web from contains textbox and insert to db button .When i write html tags inside text , the code is blocked , how can i enter information like ? <p> Hi </p> thanks
1
by: countocram | last post by:
I have big problem, I'm using preg_replace() function for my highlighter function, after searching for particular keyword, once the hightler check box is checked it will highlight the content that...
1
by: jamieg99 | last post by:
Hello, I've got an object that's being converted into SAXSource and then converted into a pdf with FOP. Some of the data however is in HTML format inside the xml tags and is being escaped (&gt;, etc)...
3
by: gaya3 | last post by:
Hi, can anyone please say me how to add <html> tags inside JTextarea? Thanks in Advance. -Thanks & Regards, Hamsa
17
by: V S Rawat | last post by:
I joined this ng and tried to post my first message that had a small php code (HTML and all). my newsserver aioe.net rejected the post saying "HTML Tags". My message was in text format, not in...
1
by: vivek kapile | last post by:
This code will help for the beginners, who want to learn, how to detect a HTML Tags inside a gridview. Before getting to the code I will give a small introduction how to work with gridview with...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.