Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conditional Blocks

 
Raj Sharma
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to write conditional blocks in DTD. For Example, the value of Element 1 in block B should be required only if the attribute of Element 1 in block A is "New".
Is there any way to code these kinds of block.
Any other approaches are also welcome.
Thanks,
Raj
 
Sanjay Mishra
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I never came across where conditional coding was done
it a DTD file.
sanjay
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way to alternate DTD declarations are INCLUDE and IGNORE sections:
<![INCLUDE[
some DTD declarations here
]]>

or
<![IGNORE
some DTD declarations here
]]>

Of course, they do not provide functionality you write about.
They do not provide it for two main reasons: first, DTD is a document-oriented validation tool and your task is really data-oriented. XML Schemas are more data-oriented and provide more sharpened validation tools. Yet not as sharp as you want There is another reason for it. Validation is a multi-layered process. Application may want to delegate some part of it to external tools, such as DTD or Schemas, but there always will be some validity constrains application need to check itself.
DTD, Schemas, or any other validating language define formal �grammar� of your data, and they validate data against formal rules. Like English grammar may say something like �if you have a noun in this place, you can put an adjective before, but you cannot have a preceding adverb�. No grammar will tell you: �if you have a noun �programmer�, you can put �smart� before, but adjectives such as �deep� or �colorful� cannot be legally used�. This is not a formal level, this is a semantic level, and, probably, your application should deal with semantic constraints on its own.
Alternatively, if W3C compliance is not a concern, you can use a language which is specially designed to validate schemas instead of defining them � shematron. It utilizes XPath expressions in its rules.

[This message has been edited by Mapraputa Is (edited June 11, 2001).]
 
Raj Sharma
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mapraputa for explaining everything in detail. Really appreciate.
Raj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic