Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is empty string valid XML?

Tags:

string

xml

Is '' a valid piece of XML? Can '' insert into oracle xblob column or XML column from MSSQL?

like image 540
Ray Lu Avatar asked Dec 17 '08 22:12

Ray Lu


People also ask

Is null valid in XML?

In an XML document, the usual way to represent a null value is to leave the element or attribute empty. Some business messages use a special value to represent a null value: <price>-999</price> .

How do I create an empty string in XML?

Ensure that the tag (e.g. %%middlename%%) contains the value null. In your message action (e.g. Publish) right click the "text (String) {XML}" node and select "Properties". Set the check box "Send NULL values". Your message action should now send an XML nil as the node value.

What is empty element in XML?

An empty element is an element that is complete by itself; it never contains other elements. Rather than being composed of a start tag, data, and an end tag, the empty element is a combined start and end tag.


2 Answers

No. The spec says a well-formed XML document satisfies:

document ::=  prolog  element  Misc*

where

element ::= EmptyElemTag
              | STag content ETag 
like image 183
David Norman Avatar answered Oct 31 '22 19:10

David Norman


It's not valid xml, but it can be inserted into an XML column in SQL Server 2005. Obviously with SQL Server 2005, you need to trade up the double quote for single quotes:

Insert Into MyTestTable(MyXmlColumn) Values('');

That works just fine - I just tested it and the insert was successful.

But Oracle does not allow empty XML. The expression XMLType('') will raise the exception "ORA-19032: Expected XML tag , got no content".

like image 37
BenAlabaster Avatar answered Oct 31 '22 19:10

BenAlabaster