Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Namespaces and attributes

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Nils_Kilden-Pedersen AT Countrywide.Com
  • To: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Namespaces and attributes
  • Date: Tue, 25 Nov 2003 15:18:29 -0800

xom-interest-bounces AT lists.ibiblio.org wrote on 11/25/2003 03:02:33 PM:

> Hmmm, I wonder if there's an inexpensive way I could test this on
> getAttributevalue (and many similar calls) to warn the user what
> they're doing wrong at least some of the time.

An attribute name cannot contain '/'. A URI doesn't have to contain this
either, but mostly do.
>From elharo AT metalab.unc.edu Tue Nov 25 18:54:13 2003
Return-Path: <elharo AT metalab.unc.edu>
Delivered-To: xom-interest AT lists.ibiblio.org
Received: from mail4.speakeasy.net (mail4.speakeasy.net [216.254.0.204])
by happyhouse.metalab.unc.edu (Postfix) with ESMTP id 3CC71200D6
for <xom-interest AT lists.ibiblio.org>;
Tue, 25 Nov 2003 18:54:13 -0500 (EST)
Received: (qmail 21464 invoked from network); 25 Nov 2003 23:54:12 -0000
Received: from unknown (HELO [192.168.254.4]) ([216.254.85.72])
(envelope-sender <elharo AT metalab.unc.edu>)
by mail4.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted SMTP
for <Nils_Kilden-Pedersen AT Countrywide.Com>; 25 Nov 2003 23:54:12 -0000
Mime-Version: 1.0
X-Sender: elharo AT mail.ibiblio.org
Message-Id: <p06010211bbe9959f1aca@[192.168.254.4]>
In-Reply-To:
<OF377406A9.60C55BE8-ON88256DE9.007F2FA0-88256DE9.00800D54 AT countrywide.com
>
References:
<OF377406A9.60C55BE8-ON88256DE9.007F2FA0-88256DE9.00800D54 AT countrywide.com
>
Date: Tue, 25 Nov 2003 18:48:59 -0500
To: Nils_Kilden-Pedersen AT Countrywide.Com
From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
Subject: Should XOM check for illegal names passed to getter methods? (Was
Re: [XOM-interest] Namespaces and attributes)
Content-Type: text/plain; charset="us-ascii" ; format="flowed"
Cc: xom-interest AT lists.ibiblio.org
X-BeenThere: xom-interest AT lists.ibiblio.org
X-Mailman-Version: 2.1.2
Precedence: list
List-Id: <xom-interest.lists.ibiblio.org>
List-Unsubscribe: <http://lists.ibiblio.org/mailman/listinfo/xom-interest>,
<mailto:xom-interest-request AT lists.ibiblio.org?subject=unsubscribe>
List-Archive: <https://lists.ibiblio.org/sympa/arc/xom-interest>
List-Post: <mailto:xom-interest AT lists.ibiblio.org>
List-Help: <mailto:sympa AT lists.ibiblio.org?subject=HELP>
List-Subscribe: <http://lists.ibiblio.org/mailman/listinfo/xom-interest>,
<mailto:xom-interest-request AT lists.ibiblio.org?subject=subscribe>
X-List-Received-Date: Tue, 25 Nov 2003 23:54:13 -0000

At 3:18 PM -0800 11/25/03, Nils_Kilden-Pedersen AT Countrywide.Com wrote:
>xom-interest-bounces AT lists.ibiblio.org wrote on 11/25/2003 03:02:33 PM:
>
>> Hmmm, I wonder if there's an inexpensive way I could test this on
>> getAttributevalue (and many similar calls) to warn the user what
>> they're doing wrong at least some of the time.
>
>An attribute name cannot contain '/'. A URI doesn't have to contain this
>either, but mostly do.

Yes. The question is whether I want to impose the cost of checking
for that on every call to getAttribute() or getAttributeValue(). I
suppose I could do this only after I've verified that no such
attribute exists. This would mean the majority of the cases where you
ask for the attribute and it exists would not pay the cost. It would
still be a hit for some cases, but probably not too bad or too common.

I've just added code to provide a more explicit message for this case
to the Verifier. Thus in the relevant attribute and element
constructors a more explicit message is provided to help developers
track down their mistakes. This does *not* change the behavior or API
in any way aside from the exception message, and should have no
performance cost in the non-exceptional case.

The question now is what to do when a getAttribute(Value) or
getChildElement(s) call is about to return null (or an empty list for
getChildElements). In that circumstance, I could easily call
Verifier.checkName() on the name passed in. If the name is not a
legal XML name this would throw an IllegalNameException, a runtime
exception. Probably most of the time this is correct because passing
an illegal name to a method is likely a programming error, unlike
passing a bad name to a constructor. However, I have not been
catching that up till now because it is not an error which would
result in malformed document. Nonetheless catching it might make make
XOM programs more robust.

What do people think? To me it feels like a good idea, but not an
essential one.
--

Elliotte Rusty Harold
elharo AT metalab.unc.edu
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA




Archive powered by MHonArc 2.6.24.

Top of Page