473,396 Members | 1,853 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,396 software developers and data experts.

Problem transforming empty element tags using XmlTransform

I'm trying to transform an xml file that contains empty short elements like
the following:

<element attrib="abc"/>

using the XmlTransform class. But I cannot seem to preserve the short format
as everytime it get's converted to the longer format of:

<element attrib="abc"></element>

I need to preserve the shorter format, has anyone else had this problem or
got a solution?

thanks
Nov 17 '05 #1
5 3071


no****@nospam.net wrote:
I'm trying to transform an xml file that contains empty short elements like
the following:

<element attrib="abc"/>

using the XmlTransform class. But I cannot seem to preserve the short format
as everytime it get's converted to the longer format of:

<element attrib="abc"></element>

I need to preserve the shorter format, has anyone else had this problem or
got a solution?


There are lots of people who report that "problem" but the usual attempt
to "solve" it is to explain that in terms of XML
<element attrib="abc"/>
and
<element attrib="abc"></element>
are absolutely equivalent so any application processing the
transformation output as XML should not have any problems or make a
difference.
Why do you think you need to preserve <element />?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 17 '05 #2
They are using Biztalk, and what is actually happening is that <element
attrib="abc"/> is actually being converted to:

<element attrib="abc">
</element>

which, because of the whitespace is causing problems. I could probably get
round this by using the indent="no" parameter in xslt but for readability
that puts everything on one line and I don't see why this should be
happening.

Using Stylus studio to debug things using the MSXML .Net parser doesn't have
this problem so I'm thinking there should be another way round it.

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...


no****@nospam.net wrote:
I'm trying to transform an xml file that contains empty short elements
like
the following:

<element attrib="abc"/>

using the XmlTransform class. But I cannot seem to preserve the short
format
as everytime it get's converted to the longer format of:

<element attrib="abc"></element>

I need to preserve the shorter format, has anyone else had this problem
or
got a solution?


There are lots of people who report that "problem" but the usual attempt
to "solve" it is to explain that in terms of XML
<element attrib="abc"/>
and
<element attrib="abc"></element>
are absolutely equivalent so any application processing the transformation
output as XML should not have any problems or make a difference.
Why do you think you need to preserve <element />?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Nov 17 '05 #3
Does this mean that there isn't a way of keeping the short tags or you just
don't know of one?

thanks
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...


no****@nospam.net wrote:
I'm trying to transform an xml file that contains empty short elements
like
the following:

<element attrib="abc"/>

using the XmlTransform class. But I cannot seem to preserve the short
format
as everytime it get's converted to the longer format of:

<element attrib="abc"></element>

I need to preserve the shorter format, has anyone else had this problem
or
got a solution?


There are lots of people who report that "problem" but the usual attempt
to "solve" it is to explain that in terms of XML
<element attrib="abc"/>
and
<element attrib="abc"></element>
are absolutely equivalent so any application processing the transformation
output as XML should not have any problems or make a difference.
Why do you think you need to preserve <element />?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Nov 17 '05 #4
Demon News wrote:
They are using Biztalk, and what is actually happening is that <element
attrib="abc"/> is actually being converted to:

<element attrib="abc">
</element>

which, because of the whitespace is causing problems. I could probably get
round this by using the indent="no" parameter in xslt but for readability
that puts everything on one line and I don't see why this should be
happening.


I only use indent="yes" for debugging, later when I'm sure the output is
correct and only read by XML-parsers, I set indent="no".

But IIRC, if you avoid whitespace in the XSLT, there won't be any in the
output either. For example:

<out:element><xslt:attribute name="attrib">
<xslt:value-of select="'foo'" /<
</xslt:attribute></out:element>

xslt:attribute will be replaced, so you can use whitespace inside it.
--
Pascal Schmitt
Nov 17 '05 #5
Thanks, I guess I'll just not use indentation. I'm still surprised that this
happens though.

"Pascal Schmitt" <ne*******@cebra.nu> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Demon News wrote:
They are using Biztalk, and what is actually happening is that <element
attrib="abc"/> is actually being converted to:

<element attrib="abc">
</element>

which, because of the whitespace is causing problems. I could probably
get round this by using the indent="no" parameter in xslt but for
readability that puts everything on one line and I don't see why this
should be happening.


I only use indent="yes" for debugging, later when I'm sure the output is
correct and only read by XML-parsers, I set indent="no".

But IIRC, if you avoid whitespace in the XSLT, there won't be any in the
output either. For example:

<out:element><xslt:attribute name="attrib">
<xslt:value-of select="'foo'" /<
</xslt:attribute></out:element>

xslt:attribute will be replaced, so you can use whitespace inside it.
--
Pascal Schmitt

Nov 17 '05 #6

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

Similar topics

13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
5
by: ChrisEvans | last post by:
Hi there, I've got an XML file which uses an XSL stylesheet. Problem is: <br /> tags don't work for me when the content is gathered from the xml. Example: <main> <title>Hi</title>
13
by: vega | last post by:
How do I detect empty tags if I have the DOM document? For example: <br /> and <br></br> I tried org.w3c.dom.Node.getFirstChild(), it returns null for both <br /> and <br></br> I also tried...
4
by: B Johnson | last post by:
I am trying to transform an xml document using an xsl document into HTML. I am getting the following error: "There are multiple root elements in the output XML." So I had the contents of...
4
by: John Bowman | last post by:
Hi, I'm not certain this is the best place to post this, but here it goes. I'm trying to get spaces to work correctly when using the WebBrowser control. Basically, I've got a valid XML...
1
by: Vidar | last post by:
I have a problem in dotNET XSL convertion object. (XMLTRANSFORM) It won't convert UTF-8 to ISO-8859-1 I use this stylesheet for konvertion: <?xml version="1.0" encoding="ISO-8859-1"?> <!--...
2
by: nospam | last post by:
I'm trying to do a transform on some xml using the XslTransform class. The input xml contains an empty element in short format like this... <element attrib="abc"/> But during the transform...
1
by: Demon News | last post by:
I'm trying to transform an xml file that contains empty short elements like the following: <element attrib="abc"/> using the XmlTransform class. But I cannot seem to preserve the short format...
1
by: Hoots | last post by:
I'm trying to transform an xml file that contains empty short elements like the following: <element attrib="abc"/> using the XmlTransform class. But I cannot seem to preserve the short format...
5
by: nospam | last post by:
I'm trying to transform an xml file that contains empty short elements like the following: <element attrib="abc"/> using the XmlTransform class. But I cannot seem to preserve the short format...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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
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,...

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.