Web Programming Notes
1. Introduction to Web Programming
- What is Web Programming?
Web programming involves creating web applications that work over the
internet. It makes websites interactive and dynamic using various
programming languages and technologies.
* Frontend: Client-side (HTML, CSS, JavaScript).
* Backend: Server-side (PHP, Python, Ruby, [Link]).
2. Introduction to SGML Features
SGML (Standard Generalized Markup Language) defines document structure.
* Custom Tags: Users can define tags like <book>.
* Flexibility: Supports creation of different markup languages.
* Structured Data: Ensures well-structured documents.
* Validation: Can be validated against DTDs (Document Type Definitions).
3. HTML, XHTML, DHTML, XML
- HTML: HyperText Markup Language for web page structure.
- XHTML: Stricter HTML, following XML rules (well-formed, case-sensitive).
- DHTML: Dynamic HTML (HTML+CSS+JavaScript) for interactive pages.
- XML: eXtensible Markup Language for storing and transporting data,
with user-defined tags.
4. HTML vs XML
HTML:
* Predefined tags (e.g., <p>, <h1>, <div>).
* Designed for presentation; lenient syntax.
XML:
* User-defined tags (e.g., <book>, <author>).
* Designed for data storage and transport; strict syntax.
5. Creating XML Documents
- Start with optional declaration: <?xml version="1.0" encoding="UTF-8"?>
- Must have a root element.
- Example:
<book>
<title>XML for Beginners</title>
<author>John Doe</author>
<year>2025</year>
</book>
6. Parsing an XML Document
- Parsing reads and extracts data from XML.
- Methods:
* DOM: Loads entire XML into memory as a tree.
* SAX: Reads XML sequentially, event-based, memory-efficient.
7. Writing Well-formed Documents
Rules for well-formed XML:
* All tags must be closed.
* Proper nesting (no overlapping).
* Single root element.
* Tags are case-sensitive.
8. Organizing Elements with Namespaces
- Namespaces prevent conflicts with same tag names.
- Example:
<book xmlns="[Link]
<title>XML for Beginners</title>
</book>
9. Defining Elements in a DTD
- DTD defines XML structure: elements, order, attributes.
- Example:
<!DOCTYPE book [
<!ELEMENT book (title, author, year)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT year (#PCDATA)>
]>
10. Declaring Elements and Attributes in a DTD
- Use <!ATTLIST> to declare attributes.
- Example:
<!ATTLIST book id ID #REQUIRED>
<book id="101">
<title>XML for Beginners</title>
<author>John Doe</author>
<year>2025</year>
</book>
Final Summary:
- Web programming: frontend (HTML/CSS/JS) and backend (PHP/Python/Node).
- SGML: base for HTML and XML, supports custom tags and validation.
- HTML vs XML: presentation vs data transport.
- XML: document must be well-formed and can use DTD for validation.
- Basic HTML tags: headings, paragraphs, formatting, lists, tables, forms.