473,508 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Allowing mis-matched tags (non-well-formed XML)

Hello,

I have an XSL file that has something like this:

<xsl:if test-condition1>
<body attribute1 attribute2>
</xsl:if>
<xsl:if test-condition2>
<body attribute3 attribute4>
</xsl:if>
[[[BODY CONTENT]]]
</body>

This fails to compile as this is not a well formed XML file
(mismatched body tag). Is there a simple workaround without
duplicating the entire body contents across both condition bodies.

-woolee_master

Apr 3 '07 #1
7 2046
On 3 Apr, 14:03, nadaha...@gmail.com wrote:
Is there a simple workaround without
duplicating the entire body contents across both condition bodies.
You need to keep your XSL source well-formed and valid.

Duplicate the <bodystart tag

Use <xsl:attribute name="..." value="..." /within your tests.

You might even use <xsl:attribute name="..." before your tests and
then just return the values for these attributes from within the tests
(check the whitespace though). I assume that you#re generating HTML
here and your "attributes" are something like "class" or "title" where
you're using the same attribute each time, but with diffferent values.

Perhaps best of all though is to set up a variable simply and cleanly
beforehand, then use it in the start tag:

<body class="{$classNames}" >
Apr 3 '07 #2
Yes, my attributes are class, title, and such like.

I had given an instance of a bigger problem I face. My overall problem
is that I want malformed HTML to be output as a result of my XSL
transformation. But the XSL style-sheet doesn't allow it. I tried
stuffing all my malformed HTML into CDATA so that XSL treats it like
data and not XML/HTML. That doesn't work because XALAN later escapes
CDATA and browsers don't render the escaped HTML.

Any help? If I am being too vague, I can mail some XSL snippets.

-woolee_master.

On Apr 3, 7:18 pm, "Andy Dingley" <ding...@codesmiths.comwrote:
On 3 Apr, 14:03, nadaha...@gmail.com wrote:
Is there a simple workaround without
duplicating the entire body contents across both condition bodies.

You need to keep your XSL source well-formed and valid.

Duplicate the <bodystart tag

Use <xsl:attribute name="..." value="..." /within your tests.

You might even use <xsl:attribute name="..." before your tests and
then just return the values for these attributes from within the tests
(check the whitespace though). I assume that you#re generating HTML
here and your "attributes" are something like "class" or "title" where
you're using the same attribute each time, but with diffferent values.

Perhaps best of all though is to set up a variable simply and cleanly
beforehand, then use it in the start tag:

<body class="{$classNames}" >

Apr 17 '07 #3
na*******@gmail.com schrieb:
I have an XSL file that has something like this:

<xsl:if test-condition1>
<body attribute1 attribute2>
</xsl:if>
<xsl:if test-condition2>
<body attribute3 attribute4>
</xsl:if>
[[[BODY CONTENT]]]
</body>
Something like:

<body>
<xsl:if test="test-condition1">
<xsl:attribute name="attribute1">...</xsl:attribute>
<xsl:attribute name="attribute2">...</xsl:attribute>
</xsl:if>
<xsl:if test="test-condition2">
<xsl:attribute name="attribute3">...</xsl:attribute>
<xsl:attribute name="attribute4">...</xsl:attribute>
</xsl:if>
[[[BODY CONTENT]]]
</body>

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Apr 17 '07 #4
na*******@gmail.com wrote:
is that I want malformed HTML to be output as a result of my XSL
transformation.
If you step outside the assumptions of the XML world, you're going to
have to fight the tools every step of the way.

For example: You could try to achieve this by setting the output to text
rather than HTML. But then you're going to have to hand-construct every
single tag in the output.

Personally, my solution would be to discard and replace whatever tool is
demanding ill-formed files, NOW. Life's too short to spend it working
around broken applications.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Apr 17 '07 #5
in message <11**********************@y5g2000hsa.googlegroups. com>,
na*******@gmail.com ('na*******@gmail.com') wrote:
Yes, my attributes are class, title, and such like.

I had given an instance of a bigger problem I face. My overall problem
is that I want malformed HTML to be output as a result of my XSL
transformation. But the XSL style-sheet doesn't allow it. I tried
stuffing all my malformed HTML into CDATA so that XSL treats it like
data and not XML/HTML. That doesn't work because XALAN later escapes
CDATA and browsers don't render the escaped HTML.

Any help? If I am being too vague, I can mail some XSL snippets.

-woolee_master.
You cannot do this. And it's a good thing that you cannot do this. The
world has much too much malformed HTML already, we don't need any more.

--
si***@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
.::;===r==\
/ /___||___\____
//==\- ||- | /__\( MS Windows IS an operating environment.
//____\__||___|_// \|: C++ IS an object oriented programming language.
\__/ ~~~~~~~~~ \__/ Citroen 2cv6 IS a four door family saloon.

Apr 17 '07 #6
na*******@gmail.com wrote:
That doesn't work because XALAN later escapes
CDATA and browsers don't render the escaped HTML.
It is possible to tell XSLT that you would prefer the content of some
elements be escaped via <![[CDATA]]section markup, rather than
character by character. See xsl:output's cdata-section-elements attribute.

But explicitly relying upon CDATA Sections is a sin and an abomination
before the eyes of the Architects.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Apr 18 '07 #7
On 17 Apr, 13:42, nadaha...@gmail.com wrote:
My overall problem
is that I want malformed HTML to be output as a result of my XSL
transformation.
No you don't.

You don't need this. There's nothing out there worth using that
requires you to do this. Why do you think you do?

If you mean "I want to generate HTML that isn't well-formed XML", then
that's fine (but isn't "malformed"). Just use

<xsl:output method="html" />

Apr 18 '07 #8

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

Similar topics

1
9917
by: Jason G. | last post by:
I have heard that you cannot use short tags and XML because of the opening line of an xml document... <?xml version="1.0"?> Consider this: <<?= '?'; ?>xml version="1.0"<?= '?'; ?>> ...
3
3168
by: Michelle | last post by:
I am trying to write a general function XML file parser, but it keeps choking when it finds embedded HTML within the text, for example: <item> <title>New PHP eBooks in PDF</title> <description>...
2
1182
by: MR | last post by:
I would like to create an htm file (using Word) that will have some free form text. However, in the free form text I would like to be able to embed some fields like Name, Address, etc. I have tried...
11
11569
by: doulos05 | last post by:
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...
1
14283
by: Andrus | last post by:
I need to remove all comments ( between <!-- and --tags) from XML string. I tried the following code but comments are still present. Or is it better to open xml string with a StreamReader, read...
1
4489
by: patelgaurav85 | last post by:
Hi, I want to convert xml in one format into another xml format shown below Input xml : <Name> <Name1> <Name11>Name11</Name11> <Name12>Name12</Name12>
1
2342
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)...
1
1354
by: aditya83 | last post by:
Hi, We are trying to create a XML extract(with the help of another tool) and then send it to IBM WCC. I am not an expert in WCC, but the team developing the front end portal has expressed their...
1
2970
by: SM | last post by:
Hello, I have a couple of XML files that represent articles. Each XML file is unique. Meaning that overall the structure is the same but some tags in the xml file are not in the same place or...
18
6512
by: malathib | last post by:
Hi, while trasforming xml to html using xslt, i dont want to lose xml tags.I want to preserve it. After transforming to html and displaying in browser and if you are right clicking and viewing...
0
7224
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
7118
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
7323
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
7379
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
7038
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
7493
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
5625
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,...
1
5049
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
4706
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.