Hi, The XML Infoset does not distinguish the two forms of writing element 'a' with empty contents: <a></a> and <a/> are the same. Those two are equivalent representantions of the same thing in the instance document. Every XML compliant parser will report those two cases the same: A SAX parser will report a startElement event, immediately followed by an endElement event. A DOM parser will construct an element node with no children.
XML Schema works over XML Infoset; it doesn't look deeper than that. If you construct an XML document, you can choose whichever form of empty elements you like more, but you shouldn't rely on it stay that way after any processing, e.g. editing or transformation. Jan Dvorak Dne čt 20. červen 2002 14:38 jste napsal(a): > Hi, > I'm not sure if it's right behaviour or not, but along the XML Schema spec > such two types in XML are supposed to be different. > > The thruth is that the only way to differ "empty" and "null" element is > possible only using XML Schema and "xsi:nill" attributes. On this level > many applications differ between these two types. > > Tobbi > ----- Original Message ----- > From: Evyatar Kafkafi > To: [EMAIL PROTECTED] > Sent: Thursday, June 20, 2002 2:16 PM > Subject: RE: <a/> and <a></a> different ? > > > My question is about the DOM - will the 2 DOM trees be the same? > According to your answer, they should be different. > > As far as I can check, they are the same ! > So after parsing the XML to DOM, I can't tell whether it was "a" having > empty string, or 'a" with no content. > > I need some way to know from DOM tree which of the 2 XMLs it was... > > Evyatar > -----Original Message----- > From: Tobbi [mailto:[EMAIL PROTECTED] > Sent: Thu, June 20, 2002 3:08 PM > To: [EMAIL PROTECTED] > Subject: Re: <a/> and <a></a> different ? > > > Hi, > I suppose that you don't get the same result parsing via SAX or DOM. > > The difference is that <a></a> means: element "a" having an empty > string as the child (or whitespace, I'm not sure) On the other side <a/> > means: element "a" with NO content, i.e. in DOM this element shouldn't have > any childs. > > Tobbi > ----- Original Message ----- > From: Evyatar Kafkafi > To: [EMAIL PROTECTED] > Sent: Thursday, June 20, 2002 1:59 PM > Subject: <a/> and <a></a> different ? > > > Hi all, > > Suppose I have one XML like this: <s><a></a></s> > and a second XML like this: <s><a/></s> > > When I parse with a DOMParser, will I get the same DOM tree for both > XMLs? When I parse with SAX Pasrer, will I get the same SAX events for both > XMLs? > > TIA > Evyatar ---------------------------------------- Content-Type: text/html; charset="windows-1255"; name="Příloha: 1" Content-Transfer-Encoding: quoted-printable Content-Description: ---------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
