473,654 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12 '05 #1
5 1419


no****@nospam.n et 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 12 '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*******@yaho o.de> wrote in message
news:ur******** ******@TK2MSFTN GP09.phx.gbl...


no****@nospam.n et 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 12 '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*******@yaho o.de> wrote in message
news:ur******** ******@TK2MSFTN GP09.phx.gbl...


no****@nospam.n et 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 12 '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><x slt: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 12 '05 #5
Thanks, I guess I'll just not use indentation. I'm still surprised that this
happens though.

"Pascal Schmitt" <ne*******@cebr a.nu> wrote in message
news:%2******** ********@TK2MSF TNGP11.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><x slt: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 12 '05 #6

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

Similar topics

13
3392
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 <foo/>) From XHTML specification:
5
1745
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
2325
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 getNodeValue(), they both returns null also. I know <br /> and <br></br> are the same from the xml spec. Is there any way to tell the different syntax using DOM parser?
4
5753
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 the loaded xml document written out on screen - copied it and placed the contents in a physical file and saved it. I then created a simple HTML
4
2213
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 document and valid XSL file that I transform into an HTML file using .NET's XmlTransform object. This is all fine except for 1 thing. The XSL has a string of " " codes inside that looks something like:
2
1532
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 it's being converted to the longer form like this... <element attrib="abc"></element>
1
1051
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 as everytime it get's converted to the longer format of: <element attrib="abc"></element>
1
1524
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 as everytime it get's converted to the longer format of: <element attrib="abc"></element>
5
3086
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 as everytime it get's converted to the longer format of: <element attrib="abc"></element>
0
8379
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
8816
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...
1
8494
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
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
5627
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();...
0
4150
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1597
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.