Hidden.text inside emphasis tag

S

Sue

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>
element.
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
#PCDATA.
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?
 
J

Joe Kesselman

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.

http://www.w3.org/TR/REC-xml/#sec-mixed-content

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,
http://www.love-song-productions.com/people/keshlam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
 
S

Sue

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.

http://www.w3.org/TR/REC-xml/#sec-mixed-content

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,http://www.love-song-productions.com/people/keshlam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail!  | "Put down the squeezebox & nobody gets hurt."

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

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top