021:239 XML+XSLT for L i b r a r ies
As sign men t 1 : Domai n m ap + sa mpl e X ML
Part%of%working%with%xml%involves%defining%a%scope%and%context%for%the%data%youâre%working%with.%
Choose%some%domain%you%want%to%work%with%â%it%could%be%a%recipe,%a%poem,%an%email.%The%
domain%itself%doesnât%have%to%be%textâbased.%It%could%be%a%movie,%something%physical,%like%a%
house,%or%something%more%conceptual,%like%friendship.%It%should%be%something%you%feel%
comfortable%describing.%Youâll%need%to%choose%a%specific%instance%of%your%domain%(for%example,%a%
recipe%for%pancakes)%but%also%be%able%to%generalize%it%(by%describing%the%characteristics%of%recipes%
in%general).%You%can%decide%how%much%to%generalize%it%â%do%you%want%to%describe%any%type%of%
movie,%or%just%horror%movies,%or%just%the%characteristics%of%really%bad%movies.%You%can%be%
subjective.%Later%on%weâll%be%more%objective,%or%at%least%weâll%be%subjective%according%to%existing%
standards%â%for%now%you%can%be%subjective%to%your%own%standards%if%you%want%to.%
1. Define%the%domain%you%want%to%describe%in%xml%in%a%sentence%or%two.%What%are%the%scope%
and%context?%
2. Map%out%your%domain,%following%the%example%on%the%website.%What%are%the%core%
characteristics%of%the%domain%youâre%interested%in?%Those%are%your%elements.%Elements%
generally%have%thingâness,%like%nouns.%Can%you%break%those%elements%down%further%into%
elements%of%their%own%(and%do%you%want%to,%given%how%you%defined%your%domain%in%step%
1)?%
3. Are%there%more%details%you%need%to%describe%and%distinguish%your%elements,%but%that%
donât%really%stand%on%their%own?%Those%are%your%attributes%â%add%them%to%your%domain%
map.%They%function%like%adjectives,%closely%associated%with%the%elements%they%describe.%
The%same%attributes%can%be%applied%to%different%elements.%
4. Choose%an%instance%or%embodiment%of%your%domain.%If%you%described%a%newspaper%
article,%choose%a%specific%article%from%The%New%York%Times,%for%example.%%
5. Open%a%new%xml%document%in%oXygen%(uncheck%the%box%that%says%âUse%DTD%or%schemaâ).%
After%the%xml%processing%instructions%(â<?xml%version="1.0"%encoding="UTFâ8"?>â),%start%
translating%your%domain%to%xml.%%
%
Remember%to%use%opening%and%closing%tags%for%every%element.%
%
<element%attribute=âvalueâ>data</element>%
%
Elements%that%conceptually%make%up%other%elements%should%be%nested,%such%as:%
%
<family>%
% <parent></parent>%
% <child></child>%
% <pets>%
% % <dog></dog>%
% % <cat></cat>%
% </pets>%
</family>%