(. behavioral patterns) , .
, . . , , . , . - , . . .
Command/, Interpreter/
Iterator/,Cursor,Mediator/ Memento/,Observer/,
- , . : Dependents (), Publish-Subscribe (-). codelab.ru codelab.ru
- .
, . , : , .
.
,
,
, .
class Command {
public:
virtual ~Command ();
virtual void Execute () = 0;
protected:
Command ();
};
class OpenCommand: public Command {
public:
OpenCommand (Application*);
virtual void Execute ();
protected:
};
void OpenCommand::Execute () {
const char* name = AskUser();
if (name!= 0) {
Document* document = new Document(name);
_application->Add(document);
document->0pen();}}
12. XML: , . XML DTD.
XML- ( , HTML) Standard Generalized Markup Language (SGML), , . XML (). XML . XML , , , . , , . "XML" .
|
|
XML , , , XML, , , , .
<book> <chapter>
<title></title>
</chapter>
<chapter>
<title> </title>
<subChapter>
<title> 1</title>
</subChapter>
<subChapter>
<title> 2</title>
</subChapter>
</chapter>
<chapter>
<title></title>
</chapter> </book>
DTD (-, ), ( ) . DTD , , , , .
<!ELEMENT people_list (person*)>
<!ELEMENT person (name, birthdate?, gender?, socialsecuritynumber?)>
<!ELEMENT name (#PCDATA) >
<!ELEMENT birthdate (#PCDATA) >
<!ELEMENT gender (#PCDATA) >
<!ELEMENT socialsecuritynumber (#PCDATA) >
: <people_list> <person>. <*> 0, 1 <person> <people_list>.
<person> <name>, <birthdate>, <gender> <socialsecuritynumber>. <?> . <name> <?>, <person> <name>. <name> . <birthdate> . <gender> . <socialsecuritynumber> . XML-, DTD:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE people_list SYSTEM "example.dtd">
<people_list>
<person>
<name>Fred Bloggs</name>
<birthdate>27/11/2008</birthdate>
<gender>Male</gender>
<socialsecuritynumber>1234567890</socialsecuritynumber>
</person>
</people_list>
XML .
XML- Standard Generalized Markup Language (SGML), , . XML (). XML . XML , , , . , , . "XML" .
(Schemas) XML-. DTD, , , . , XML- XML.
|
|
XML schema: XML-, , , . .
XML. , . , , - , . , , :
<schema id="OurSchema">
<elementType id="#title">
<string/>
</elementType>
<elementType id="photo">
<element type="#title">
<attribute name="src"/>
</elementType>
<elementType id="gallery">
<element type="#photo">
</elementType>
</schema>
XML- , - . .. , :
<gallery>
<photo id="1"><title>My computer</title></photo>
<photo id="2"><title>My family</title></photo>
<photo id="3"><title>My dog</title></photo>
</gallery>