473,889 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Xalan - empty element

Hi NG,

how can I force Xalan (Java) not to create an empty element when there is
nothing between begin and end tag, which means that e.g.

<myTag></myTag>

....does not become...

<myTag/>

?

thx,
Albert
Sep 9 '06 #1
7 2390
Albert Greinöcker wrote:
Hi NG,

how can I force Xalan (Java) not to create an empty element when there is
nothing between begin and end tag, which means that e.g.

<myTag></myTag>

...does not become...

<myTag/ >
They are both exactly the same; an empty element. the string
representations (serializations ) are different; the meaning is the same.

Maybe there is an option in the class you use for serializing. Anyway,
that is where it happens.

Søren
Sep 9 '06 #2
Hi Soren,

yes, I agree, it should be, but I observed that some browsers (particularly
the IE 6) do have problems with some empty tags (in case of <script/>,
<textarea/>)

Albert
Sep 9 '06 #3
Albert Greinöcker wrote:
how can I force Xalan (Java) not to create an empty element when there is
nothing between begin and end tag, which means that e.g.
<myTag></myTag>
...does not become...
<myTag/>
If it really matters to you, you can try to find or write a SAX
serializer that handles this as a special case, ask Xalan to output SAX,
and plug the two together. Or adapt Xalan's existing serializer code;
one of the advantages of open-source projects is that you can alter them
and/or use them as a starting point for specialized tools. (You might
want to compare the XML and HTML serializers; I think the latter has
some similar tweaks.)

But personally, I would suggest you fix whatever downstream tool isn't
correctly handling <myTag/>. XML considers the two forms precisely
equivalent to each other, so you're asking for a difference that should
make no difference.

(Xalan has its own mailing list, which is generally a better place to
ask questions which are specific to that processor. But this one's a
general enough issue that I thought it was worth answering here.)


--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Sep 9 '06 #4


Albert Greinöcker wrote:

yes, I agree, it should be, but I observed that some browsers (particularly
the IE 6) do have problems with some empty tags (in case of <script/>,
<textarea/>)
Well if you send text/html to IE then it parses according to SGML/HTML
rules and not XML rules and HTML mandates <script
type="text/javascript"></scriptand not <script/or </script />.
If you send text/xml or application/xml to IE then it parses with MSXML
as its XML parser and I am sure that does not have any problems with
<script/or <textarea/>, only it only sees those as XML elements
without any meaning and not something to render.

If you use XSLT to transform XML to HTML then make sure you use e.g.
<xsl:output method="html"/>
and use HTML elements like e.g. script in no namespace, that way they
will end up as <script></scriptwhen the XSLT processor serializes the
XSLT result tree.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 9 '06 #5
Martin Honnen wrote:
If you use XSLT to transform XML to HTML then make sure you use e.g.
<xsl:output method="html"/>
Absolutely. Or generate XHTML and make sure the downstream tool supports
that newer syntax.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Sep 9 '06 #6
Albert Greinöcker wrote:
Hi NG,

how can I force Xalan (Java) not to create an empty element when there is
nothing between begin and end tag, which means that e.g.

<myTag></myTag>

...does not become...

<myTag/>
Why? They are both the same in effect (perhaps not in intention :-)

///Peter
Sep 9 '06 #7
Albert Greinöcker wrote:
Hi Soren,

yes, I agree, it should be, but I observed that some browsers (particularly
the IE 6) do have problems with some empty tags (in case of <script/>,
<textarea/>)
Don't use broken software for XML.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Sep 9 '06 #8

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

Similar topics

1
5686
by: Hyunchan Kim | last post by:
To indent xml file, I made an instance of Transformer from Templates using following. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt" version="1.0"> <xsl:output method="xml" indent="yes" xalan:indent-amount="4"/> <xsl:template match="/">
1
1811
by: Brian J. Sayatovic | last post by:
I'm using Xalan-J to loop through some nodes with an xsl:for-each element, presumably in document order. As far as I can tell, the XSL speciciation says that a for-each element will loop through the nodeset in document order, meaning the order the elements occur in the document. Does Xalan-J obey this rule? I'm encountering some oddities that could be explained if Xalan-J does not adhere to this, but it is a very rare circumstance, so...
0
2240
by: Arjen Haayman | last post by:
Hello, I'm using Xalan and have written Java classes as extension functions. According the documentation the return value of an extension function can be a Result tree fragment: (== org.w3c.doc.DocumentFragment) Now I can't figure out how to create an empty DocumentFragment from a Java class that has been created in an XSL stylesheet
1
2311
by: Fisch von Gestern | last post by:
I have tried to run the extension function/element examples provided with the Xalan-J download. I believe that my classpath is correct, and that my versions are up-to-date. However, I can't get past the following error. Any help, please? =========================================================================== C:\xalan>test C:\xalan>REM @echo off
7
2149
by: Ganesh Gella | last post by:
Hi All, I am planning to use Xalan to transform XML data by applying xls stylesheets. Here tricky part is, Xalan provides several C++ APIs, which are very much useful if our requirement is just inputting a file and getting a file. Or giving a xerces dom and get a new xerces dom. I would like to know whether any of you tried with their own custom
5
1784
by: John | last post by:
I'm trying to generate HTML using a SAX TransformHandler. The problem I'm having is related to the xalan transformer using the shorthand notation when it writes out an empty textarea tag. My code works fine when xalan.jar is not in my classpath. But when xalan.jar is in the classpath, the generated html incorrectly uses the shorthand notation for writing out an empty textarea tag. Correct output: C:\test>java Test
1
1672
by: pgreaves | last post by:
hi there i have developed a style sheet that works fine in the XML perspective of Rational Software architect, but when i add it to my application, it appears to match no nodes. my XSL that matches nodes looks like this: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7
4131
by: RC | last post by:
First, let me say I couldn't find a group discuss XML/XSLT. So I only choose the closest groups to post this message. Here is part of my *.xsl file <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" xmlns:my-javascript-ext="my-ext1" extension-element-prefixes="my-javascript-ext"
7
3364
by: Xh | last post by:
Hi All, I have problems with generating valid HTML output there are few HTML elements that i don't what to output as <tagname/> but as <tagname></tagnamebut Xalan keeps generating them as <tagname/> there are few really annoying situations where adding   to some HTML elements is necessary:
0
9962
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9810
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11198
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10791
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9609
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7150
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4647
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 we have to send another system
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3256
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.