A Gentle Introduction to
xml
Additional Questions
Question 1: Union Jack
The Union Jack is said to consist of three flags overlaid.
The Union Jack is easy to draw incorrectly. We can overlay the three Saints' flags
- St.Andrew, St. Patrick and St. George - but:
The red X of St. Patrick must lose half of its width - the anti-clockwise
half.
The flag of St. George must include a white border.
Question 2: Stars
We can give an element an id. The use element allows us
to reuse that node in another context.
US Flag
In this example we have a five pointed star defined as star
it gets used three times in different positions.
Complete the row of six stars across the top of the blue rectangle.
You can use the following to define a group of six stars.
Insert the text just after the definition
of the star. We can use this several times as <use xlink:href="#row6" y="3"/>
<g id="row6">
<use xlink:href="#star" x="1"/>
<use xlink:href="#star" x="3"/>
<use xlink:href="#star" x="5"/>
<use xlink:href="#star" x="7"/>
<use xlink:href="#star" x="11"/>
</g>
Using similar techniques you can create a 5 x 4 grid of stars, these
can be used to complete the "stars" part or the stars and stripes.
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "../../svg11-flat.dtd">
<svg width="19cm" height="10cm" viewBox="0 0 1.9 1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path id="star" fill="white" transform="scale(0.0308,0.0308)"
d="M 0 -1 L 0.588 0.809 -0.951 -0.309 0.951 -0.309 -0.588 0.809 z"/>
</defs>
<rect x="0" y="0" width="0.76" height="0.5385" fill="blue"/>
<g transform="translate(0.063,0.063)">
<g id="row6">
<use xlink:href="#star"/>
<g transform="translate(0.126,0)" id="row5">
<use xlink:href="#star"/>
<g transform="translate(0.126,0)">
<use xlink:href="#star"/>
<g transform="translate(0.126,0)">
<use xlink:href="#star"/>
<g transform="translate(0.126,0)">
<use xlink:href="#star"/>
<g transform="translate(0.126,0)">
<use xlink:href="#star"/>
</g></g></g></g></g></g>
<g transform="translate(0,0.108)">
<use xlink:href="#row6"/>
<g transform="translate(0,0.108)">
<use xlink:href="#row6"/>
<g transform="translate(0,0.108)">
<use xlink:href="#row6"/>
<g transform="translate(0,0.108)">
<use xlink:href="#row6"/>
</g></g></g></g>
</g>
<g transform="translate(0,0.108)">
<use xlink:href="#row5"/>
<g transform="translate(0,0.108)">
<use xlink:href="#row5"/>
<g transform="translate(0,0.108)">
<use xlink:href="#row5"/>
<g transform="translate(0,0.108)">
<use xlink:href="#row5"/>
</g></g></g></g>
</svg>
validate
Batik Browser rsvg
Question 3: Stripes
Add the seven red stripes before the stars.
You can draw each stripe either as a line or as a rectangle.
Working in 13th's is a little clumsy so you may enclose all of the
stripes in a g element - we can use the transform "scale" so that we
can work with a rectangle that is one unit wide and 13 units high.
<g transform="scale(1.9,0.0769)">
<line x1="0" x2="1" y1=".5" y2=".5" stroke="red"/>
</g>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"../../svg10.dtd">
<svg width="19cm" height="10cm" viewBox="0 0 1.9 1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Blue background -->
<defs>
<path id="star" fill="white" transform="scale(0.5,0.583)"
d="M 0 -1 L 0.588 0.809 -0.951 -0.309 0.951 -0.309 -0.588 0.809 z"/>
<g id="row6">
<g id="row5">
<use xlink:href="#star" x="1"/>
<use xlink:href="#star" x="3"/>
<use xlink:href="#star" x="5"/>
<use xlink:href="#star" x="7"/>
<use xlink:href="#star" x="9"/>
</g>
<use xlink:href="#star" x="11"/>
</g>
<rect width="1.9" height="1" fill="rgb(196,0,67)" id="stripe"/>
</defs>
<g transform="scale(1,0.07692)"> <!-- 1/13 on the y scale -->
<use xlink:href="#stripe" y="0"/>
<use xlink:href="#stripe" y="2"/>
<use xlink:href="#stripe" y="4"/>
<use xlink:href="#stripe" y="6"/>
<use xlink:href="#stripe" y="8"/>
<use xlink:href="#stripe" y="10"/>
<use xlink:href="#stripe" y="12"/>
</g>
<rect x="0" y="0" width="0.76" height="0.5385" fill="rgb(0,38,84)"/>
<g transform="scale(0.063,0.054)">
<use xlink:href="#row6" y="1"/>
<use xlink:href="#row6" y="3"/>
<use xlink:href="#row6" y="5"/>
<use xlink:href="#row6" y="7"/>
<use xlink:href="#row6" y="9"/>
<g transform="translate(1,1)">
<use xlink:href="#row5" y="1"/>
<use xlink:href="#row5" y="3"/>
<use xlink:href="#row5" y="5"/>
<use xlink:href="#row5" y="7"/>
</g>
</g>
</svg>
validate
Batik Browser rsvg
Question 4: Namibia
The flag for Namibia is particularly attractive, it presents an interesting
challenge.
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"../../svg10.dtd">
<svg width="15cm" height="10cm" viewBox="0 0 15 10"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<path fill='blue' d='M 0 0 12 0 0 8 Z'/>
<path fill='red' d='M 13 0 15 0 15 1.3333 2 10 0 10 0 8.6667 Z'/>
<path fill='green' d='M 3 10 15 2 15 10 Z'/>
<g transform='translate(3,3)'>
<g id='s3'>
<!-- sin(15) is 0.2588; cos(15) is 0.9659 -->
<path id='s' fill='yellow' d='M -0.2588 0.9659 0 1.5 0.2588 0.9659 z'/>
<use xlink:href='#s' transform='rotate(30)'/>
<use xlink:href='#s' transform='rotate(60)'/>
</g>
<use xlink:href='#s3' transform='rotate(90)'/>
<use xlink:href='#s3' transform='rotate(180)'/>
<use xlink:href='#s3' transform='rotate(270)'/>
</g>
<circle cx='3' cy='3' r='1' fill='blue'/>
<circle cx='3' cy='3' r='.85' fill='yellow'/>
</svg>
validate
Batik Browser rsvg