Hidden.text inside emphasis tag

Discussion in 'XML' started by Sue, Jan 29, 2010.

  1. Sue

    Sue Guest

    I am trying to use <emphasis> tag to encapsulate the target word/
    phrase and the <hidden.text> element to encapsulate the definition
    with the <hidden.text> element contained within the <emphasis>
    This requires a structural change to the DTD. So We have defined this
    in DTD as :
    <!ELEMENT emphasis (#PCDATA, hidden.text?, #PCDATA)>
    DTD validation fails in this case because of the 2nd occurrence of
    If I change the DTD structure to:
    <!ELEMENT emphasis (text1, hidden.text?, text2)>
    <!ELEMENT text1 (#PCDATA)>
    <!ELEMENT text2 (#PCDATA)>
    This means that I need to have additional 2 tags for text1 and text2
    in the XML file to make the XML valid.

    Can anyone of you think of any other solution to this problem?
    Sue, Jan 29, 2010
    1. Advertisements

  2. Can anyone of you think of any other solution to this problem?

    Go with mixed content. It won't let you constrain order or frequency of
    the content, but it will let you mix text and structure.


    In this case,
    <!ELEMENT emphasis (#PCDATA|hidden.text)* >

    If you want to constrain things more tightly than that, DTDs do require
    that you introduce additional levels of structure. The alternative is to
    switch from DTDs to XML Schemas (http://www.w3.org/XML/Schema), assuming
    your tools will support them. (Most should, these days.) Schemas take
    some getting used to, but they're a more powerful constraint and typing
    system, and unlike DTDs they support XML Namespaces properly.

    Or you can leave it loose at the validation level and impose additional
    structural constraints in the application code. DTDs or Schemas aren't
    intended to completely define the structure of the markup language;
    they're just "higher-level syntax checking". The semantic rules almost
    always wind up having to be imposed by the applications.

    Joe Kesselman,

    {} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
    /\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
    Joe Kesselman, Jan 30, 2010
    1. Advertisements

  3. Sue

    Sue Guest

    Thanks Joe.
    I think <!ELEMENT emphasis (#PCDATA|hidden.text)* > is the best
    option for me.
    Sue, Feb 2, 2010
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.