473,624 Members | 2,238 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3674
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:annotatio n>
<xs:documentati on>Mother</xs:documentatio n>
</xs:annotation>
<xs:simpleTyp e>
<xs:restricti on 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
3049
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 contents of these tags based on the rules applicable to their parent tags. For example, if my schema looks something like this: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Parent"> <xs:complexType>
0
3716
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 User's Guide page and latest jing version 20030619 from jing home page. I can run jing successfully from command line like this (which I guess proves that schema should be correct) C:\Temp\APU> java -jar jing.jar schema.xsd valid.xml
13
2324
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?
2
1937
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 validation controls) display when the controls to validate loose focus and not only when the submit button (with causesvalidation=true ) is pushed.
3
5057
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). I changed the data type for the structure that contains the XML data from the default "String" to "xml.xmldocument" to enable easy filling of the data. my client code creates an XML document class, fills the data using standard xml dom...
2
1776
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 XmlValidatingReader in .NET 1.1. If the document contains the above element with no data, for example:
2
9100
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 XmlValidatingReader in .NET 1.1. If the document contains the above element with no data, for example:
1
2876
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 schema, I get XML errors (blue squigglies) in a few places, which indicates to me that I should get validation errors while validating through code. When I try to validate an invalid document, I never get any validation errors. I have tried many...
1
1200
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 create an XML, and this is to iterate through all the objects that needs to be serialized into the XML and then use toXML()-methods in each object instance that should appear in the XML. In Java, you could pass a StringBuffer which will then be
0
8170
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
8619
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...
1
8334
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
7158
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...
1
6108
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
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
4078
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...
1
2604
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
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.