Zoo tutorials: [ SQL | Linux | XML ]

A Gentle Introduction to xml

Using modular xhtml II
With answers

Using modular xhtml

The XHTML DTD includes a number of entities that we may define before importing the code. If we define the entity Inline.extra those elements will become part of the "new" XHTML.

In this example we want to create two new elements <hint> and <hint>. The hint node should be block level, the tip element should be inline. Both new nodes should support the attribute tease.

To complete this we must define %Block.extra and %Inline.extra before we realise the %xhtml; entity.

%Block.extra;
Define this to insert new elements. The new elements should be separated by the |, the first new element should be preceded by |
%Inline.extra;
As above, but these elements may appear at the paragraph level and not at the block level.
%Block.mix;
This represents the list of block level elements including the new ones defined as Block.extra.
%Common.attrib;
A list of common attributes - most normal html elements support these, they include title, class, onclick. We woudl normally include these attributes in any new elements.
%span.element;
We can set this entity to IGNORE - doing so will prevent the span element from being defined.

ValidInvalid
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A normal XHTML element.</p>
  <hint>An enhanced element.</hint>
</body></html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p wrong="1">An invalid XHTML element.</p>
  <hint>An enhanced element.</hint>
</body></html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>Life, the universe, everything?</p>
  <hint tease="Here's a hint">
   42</hint>
</body></html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A normal XHTML element.</p>
  <hunt>An enhanced element.</hunt>
</body></html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A normal XHTML element.</p>
  <hint>An <i>enhancment</i>.</hint>
</body></html>

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A normal XHTML element.</p>
  <tip>Tip should not be allowed
       at block level.</tip>
</body></html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A <tip>tipped</tip> element.</p>
  <hint>An <tip>enhancment</tip>.</hint>
</body></html>

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A normal XHTML element.</p>
  <tip>Tip should not be allowed
       at block level.</tip>
</body></html>

Using modular xhtml

Implement the following features.


ValidInvalid
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A normal XHTML element.</p>
</body></html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>An invalid XHTML element.</p>
  <table><tr><td/></tr></table>
</body></html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A normal XHTML 
    <caption>element</caption>.</p>
</body></html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A normal XHTML element.</p>
  <caption/>
</body></html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A normal XHTML
    <caption title='E'>element</caption>.</p>
</body></html>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html SYSTEM "xhtmlplus.dtd">
<html><head><title/></head>
<body>
  <p>A normal XHTML
    <caption href='E'>element</caption>.</p>
</body></html>