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

when will empty tags pass schema validation?

My question is simply: under what conditions will empty tags of the
form <MOM></MOM> pass schema validation? Of course, the mirror
question is: under what conditions will empty tags fail validation?
The former seems to be an easier question to answer.

XML files will arrive from around the world and must be schema
validated before further processing and loading into a database, so I'm
trying to foresee the various layouts that might be submitted. I can
anticipate suppliers starting with a template, filling in needed
elements, and sending the file with empty tags in conditional segments
with mandatory and conditional elements. I understand the role of
restrictions, but there are about a dozen record types, dozens of
segments, and hundreds of elements (some of which are sometimes
mandatory, sometimes conditional, and sometimes
conditionally-mandatory). One schema is 230 pages.

I already created a test file where a conditional segment had empty
tags and validation failed.

Thanks

May 4 '06 #1
5 3653
wolf_y wrote:
My question is simply: under what conditions will empty tags of the
form <MOM></MOM> pass schema validation?


Semantically identical to <MOM/>, in XML. Therefore, they will pass in
the same conditions where <MOM/> would pass: When the schema accepts
that tag and does not require that it have any content.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
May 4 '06 #2
Thanks for answering, but maybe I should have led with my disclaimer:
I'm a newbie to XML, primarily program in SAS, and consulted online
documentation.

Some of my confusion stems from the way terms such as empty, missing,
null, and blank are used/handled in different languages. I don't mind
reading docs, but I can't find an answer I understand at
http://www.w3.org/ or url links I've found.

I don't want to create an empty element, but need to know under what
circumstances an empty element will pass schema checks, so that the
backend processing in SAS can react correctly when it's time to load
the data. There are 5 SAS programmers sharing responsibility for
writing the load routines and I was chosen to explain what to expect
after validation. There might be circumstances where an empty element
is allowed and others where we want to reject the file, both based on
the same element, depending upon the XML file provider or segment.

There are 4 levels of schema involved. Here's an example of an element
in the Level 3 schema:

<xs:element name="MOM">
<xs:annotation>
<xs:documentation>Mother</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="25"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

I understand that because of minLength this element must have at least
one character. In a simple test, whitespace <MOM> </MOM> passes (is
this a blank in XML?) whereas <MOM></MOM> doesn't (null or empty?). An
element defined with type=xs:integer fails in both circumstances.

Is there any type (or attribute?) where both <MOM></MOM> and <MOM>
</MOM> passes validation? Or must an element be explicitly defined as
permitting Empty(nil?) values? Or must I test each unique element?

I hope this makes sense.

May 4 '06 #3
wolf_y wrote:
Is there any type (or attribute?) where both <MOM></MOM> and <MOM>
</MOM> passes validation?


Sure. If minimum length had been zero (or had not been explicitly set)
for the xs:string example, both would pass.

It's really a matter of what that specific schema has said the datatype
is (which controls whether empty is syntactically acceptable) and what
additional constraints (which controls whether empty is semantically
acceptable for validation purposes).

Nillable is a different concept, having to do with the concept of
"explicitly has no meaningful value" rather than either "value is empty"
or "element was not present". It may make more sense to folks who've
worked with databases that support this idea.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
May 4 '06 #4
> It's really a matter of what that specific schema has said the datatype
is (which controls whether empty is syntactically acceptable) and what
additional constraints (which controls whether empty is semantically
acceptable for validation purposes).


You've helped by confirming my take on what I've read, and I'll
continue to reread W3C docs. Since element properties are derived and
there are so many elements, it looks like my safest strategy is to
generate test files under both scenarios and see what happens.

May 5 '06 #5
wolf_y wrote:
Thanks for answering, but maybe I should have led with my disclaimer:
I'm a newbie to XML, primarily program in SAS, and consulted online
documentation.

Some of my confusion stems from the way terms such as empty, missing,
null, and blank are used/handled in different languages. I don't mind
reading docs, but I can't find an answer I understand at
http://www.w3.org/ or url links I've found.

I don't want to create an empty element, but need to know under what
circumstances an empty element will pass schema checks,


I think the confusion arises from the two different meanings of the word.

a) EMPTY (in caps) is an XML keyword used to declare that a certain
element type can *never* have any content (neither character data
content nor other elements)

b) empty (in lowercase) is just an adjective meaning "with no content";
it doesn't specify whether content is permitted or not, it simply
says that there isn't any content at the moment.

An element type declared as EMPTY can be represented as <foo/> or as
<foo></foo>. The first is often recommended because it is unambiguous
and there is no possibility of anyone ever manually inserting any
content and thereby breaking the document model.

An element type declared *with* content *may* be empty on some
occasions (like this <name></name>) but that does not necessarily mean
that it was declared EMPTY: you'd have to consult the Schema or DTD
to find that out.

So an empty element like <name></name> will pass a validation check
either

a) if it was declared EMPTY, or
b) it was declared with optional content and just doesn't happen to
have any right now.

An element like <foo/> will only pass a validation check if it was
declared EMPTY.

(In both cases I am assuming there are no compulsory attributes.)

///Peter
--
XML FAQ: http://xml.silmaril.ie/
May 5 '06 #6

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

Similar topics

4
by: Jim Whitehead | last post by:
If I have a well-formed XML document, can I somehow tell a validating parser to ignore selected tags? I want these tags to be ignored for validation purposes, bit I still want to validate the...
0
by: Jari Kujansuu | last post by:
I am trying to learn to use jing through JARV interface and I have read JARV User's Guide (http://iso-relax.sourceforge.net/JARV/JARV.html). I have downloaded jingjarv-examples.zip from JARV...
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...
2
by: Humberto Alvarez | last post by:
Hi All I'm using asp requiredfieldvalidator and regularexpressionvalidator to validate a text field and a file input field respectively. The validation messages (the text property of the...
3
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb)....
2
by: craig.wagner | last post by:
I have an element in my schema defined as follows: <xs:element name="BillingDate" type="xs:dateTime" nillable="true" minOccurs="0"/> I use the schema to validate incoming documents using an...
2
by: craig.wagner | last post by:
I have an element in my schema defined as follows: <xs:element name="BillingDate" type="xs:dateTime" nillable="true" minOccurs="0"/> I use the schema to validate incoming documents using an...
1
by: Chris Lieb | last post by:
I have an XML Schema file that I know is correct becuase I currently use it in a VB6 program to validate XML documents. Also, if I load an XML file into VS2005 that is not valid against this...
1
by: msaladin | last post by:
Hi all, I'd like to list some arguments for using DOM when creating an XML message. For me, there is only one way to create complex XMLs, that is using DOM. There is of course another way to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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...

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.