Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   Attribute value and blank entity (http://www.velocityreviews.com/forums/t458817-attribute-value-and-blank-entity.html)

Max 03-04-2007 07:51 PM

Attribute value and blank entity
 
Hello!

I would want to know if attributes values can be entity references and
if the parser, during processing, can replace with blank string a non
registered entity.

Eg:
<example val="&entity1;&entity2;"></example>

&entity1; is a registered internal/external general entity
&entity1; has replacement text = "value"

&entity2; is a non registered internal/external general entity

Results:
<example val="value"></example>

Thanks,

Max

Joe Kesselman 03-04-2007 07:54 PM

Re: Attribute value and blank entity
 
Max wrote:
> I would want to know if attributes values can be entity references


Yes, as long as the entity value is syntactically valid to be an
attribute value.

> if the parser, during processing, can replace with blank string a non
> registered entity.


An undefined entity is an error.
http://www.w3.org/TR/2006/REC-xml11-...wf-entdeclared
http://www.w3.org/TR/2006/REC-xml11-...vc-entdeclared

If you need a replacement mechanism that can support defaults, entity
references aren't it. I'd suggest investigating something like XSLT,
possibly using the Literal Result Element As Stylesheet spproach so your
source document is invoked as the stylesheet and AVTs which reference a
values file via document() are used to fill in the gap.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry

Richard Tobin 03-05-2007 01:50 PM

Re: Attribute value and blank entity
 
In article <TsOdnd1_c-GRuXbYnZ2dnUVZ_v-tnZ2d@comcast.com>,
Joe Kesselman <keshlam-nospam@comcast.net> wrote:

>> I would want to know if attributes values can be entity references


>Yes, as long as the entity value is syntactically valid to be an
>attribute value.


Attribute values can't contain references to external entities, only
internal ones.

http://www.w3.org/TR/REC-xml/#NoExternalRefsa

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.

Max 03-05-2007 05:13 PM

Re: Attribute value and blank entity
 
Joe Kesselman ha scritto:
> An undefined entity is an error.


Thanks Kesselman!

what type of error is it generated?

Max

Joseph Kesselman 03-05-2007 05:16 PM

Re: Attribute value and blank entity
 
Max wrote:
> what type of error is it generated?


Check the documentation for the parser you're using.


--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden

Peter Flynn 03-05-2007 10:54 PM

Re: Attribute value and blank entity
 
Richard Tobin wrote:
> In article <TsOdnd1_c-GRuXbYnZ2dnUVZ_v-tnZ2d@comcast.com>,
> Joe Kesselman <keshlam-nospam@comcast.net> wrote:
>
>>> I would want to know if attributes values can be entity references

>
>> Yes, as long as the entity value is syntactically valid to be an
>> attribute value.

>
> Attribute values can't contain references to external entities, only
> internal ones.
>
> http://www.w3.org/TR/REC-xml/#NoExternalRefsa


The spec is misleading. AFAIK only XML external entity references are
forbidden in attribute values. Data external entities should be OK, eg

<?xml version="1.0"?>
<!DOCTYPE foo [
<!ELEMENT foo EMPTY>
<!ATTLIST foo bar ENTITY #REQUIRED>
<!NOTATION doc SYSTEM "http://www.microsoft.com/">
<!ENTITY stuff SYSTEM "myletter.doc" NDATA doc>
]>
<foo bar="stuff"/>

///Peter
--
XML FAQ: http://xml.silmaril.ie/

Joe Kesselman 03-06-2007 01:48 AM

Re: Attribute value and blank entity
 
For an explanation of what that rule means, from one of the folks who
defined it, see Tim Bray's _Annotated_XML_Specification_. One copy can
be found at

http://www.xml.com/axml/testaxml.htm

If you scroll or search down to "Well-Formedness Constraint: No External
Entity References", then click on the "(T)" icon following that
sentence, the second window will bring up the justification for why it
really does mean exactly what it says.


The Annotated XML Spec, by the way, is an absolutely invaluable resource
if you're trying to figure out what the spec really means, or why it is
as it is, or if you just want to better understand the philosophy behind
the original design of XML. Highly recommended resource. The only
complaint anyone has been able to make is that it's specifically based
on XML 1.0... and Tim Bray has said that he simply doesn't have the time
and energy to tackle updating it for XML 1.1.


By the way, when reading W3C specs, don't forget to check the errata
documents too. Sometimes there is newer information there, and often the
history of how the document has been clarified is enlightening... at
least for us language lawyers. (Reading specs is a skill worth
acquiring, by the way.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry

Richard Tobin 03-06-2007 12:30 PM

Re: Attribute value and blank entity
 
In article <553le3F21r00dU1@mid.individual.net>,
Peter Flynn <remove.nosp@m.from.email.address> wrote:

>> Attribute values can't contain references to external entities, only
>> internal ones.


>> http://www.w3.org/TR/REC-xml/#NoExternalRefsa


>The spec is misleading. AFAIK only XML external entity references are
>forbidden in attribute values. Data external entities should be OK, eg


You're using SGML terminology I think. XML has parsed and unparsed
entities. Only entity references that are to parsed internal entities
can occur in attribute values. The names of unparsed entities can
appear *as* entity values: as your example shows, they don't use the
&name; syntax. The term "entity reference" is not used for unparsed
entities in the XML spec, see

http://www.w3.org/TR/REC-xml/#textent

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.

Joseph Kesselman 03-06-2007 04:42 PM

Re: Attribute value and blank entity
 
Max wrote:
> Ehm... i'm programming my xml parser with javascript... What type of
> error you think i have to generate?


If you're writing your parser to conform to one of the standard parser
APIs (SAX/JAXP), those specify how errors are presented. If you're doing
it from scratch, it's up to you to define it and document it... though
I'd suggest you look at those (and at the DOM errors) for examples of
how people have reported these in the past.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden

Max 03-06-2007 04:43 PM

Re: Attribute value and blank entity
 
Joseph Kesselman ha scritto:

> Check the documentation for the parser you're using.


Ehm... i'm programming my xml parser with javascript... What type of
error you think i have to generate?

Max


All times are GMT. The time now is 07:26 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.