Attribute value and blank entity

Discussion in 'XML' started by Max, Mar 4, 2007.

  1. Max

    Max Guest

    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
    Max, Mar 4, 2007
    #1
    1. Advertising

  2. 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-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.

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Mar 4, 2007
    #2
    1. Advertising

  3. In article <>,
    Joe Kesselman <> 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.
    Richard Tobin, Mar 5, 2007
    #3
  4. Max

    Max Guest

    Joe Kesselman ha scritto:
    > An undefined entity is an error.


    Thanks Kesselman!

    what type of error is it generated?

    Max
    Max, Mar 5, 2007
    #4
  5. 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
    Joseph Kesselman, Mar 5, 2007
    #5
  6. Max

    Peter Flynn Guest

    Richard Tobin wrote:
    > In article <>,
    > Joe Kesselman <> 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/
    Peter Flynn, Mar 5, 2007
    #6
  7. 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
    Joe Kesselman, Mar 6, 2007
    #7
  8. In article <>,
    Peter Flynn <> 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.
    Richard Tobin, Mar 6, 2007
    #8
  9. 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
    Joseph Kesselman, Mar 6, 2007
    #9
  10. Max

    Max Guest

    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
    Max, Mar 6, 2007
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vineeth
    Replies:
    3
    Views:
    353
    Vineeth
    Nov 3, 2004
  2. Mateusz Loskot
    Replies:
    5
    Views:
    1,289
    Mateusz Loskot
    Oct 23, 2005
  3. Replies:
    1
    Views:
    4,264
    Joe Kesselman
    Aug 2, 2006
  4. Replies:
    8
    Views:
    521
  5. markla
    Replies:
    1
    Views:
    540
    Steven Cheng
    Oct 6, 2008
Loading...

Share This Page