Attribute value and blank entity

M

Max

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
 
J

Joe Kesselman

Max said:
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-20060816/#wf-entdeclared
http://www.w3.org/TR/2006/REC-xml11-20060816/#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.
 
P

Peter Flynn

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[/QUOTE]

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
 
J

Joe Kesselman

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.)
 
R

Richard Tobin

Attribute values can't contain references to external entities, only
internal ones.
http://www.w3.org/TR/REC-xml/#NoExternalRefsa
[/QUOTE]
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
 
J

Joseph Kesselman

Max said:
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.
 
M

Max

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top