Hallo Leute. Ich habe eine eigentlich relativ einfache Aufgabe und soll diese in XML, DTD und auch XML-Schema umwandeln. XML und DTD habe ich hier einmal vorbereitet und würde euch das gerne checken lassen. Aber ein Punkt ist mir ein Dorn im Auge, der wahrscheinlich so auch nicht richtig umgesetzt ist, aber dazu später. Die Aufgabe:
Customers can make purchase orders.
A purchase order includes at least one order position (product name, quantity, and price are obligatory; comment and shipping date are optional). A purchase order has a date (order date) and an optional comment.
Customers can specify different addresses (billing and shipping). Only the shipping address is required.
Meine erstellte XML:
Meine erstellte DTD:
Der Punkt "can specify different addresses" gepaart mit "Only the shipping address is required" ist mir da ein Dorn im Auge. Weil ich das ja so nicht wirklich validiert habe und ich aber auch nicht wüsste wie, außer tatsächlich zwei komplett verschiedene Adresselemente zu erstellen und billing dann einmal mit einem ? Indikator zu versehen für den optionalen Aspekt.
Dass ich Comment als Element nur einmal haben darf ist richtig oder? Die Anordnung ist soweit ich weiß egal.
Customers can make purchase orders.
A purchase order includes at least one order position (product name, quantity, and price are obligatory; comment and shipping date are optional). A purchase order has a date (order date) and an optional comment.
Customers can specify different addresses (billing and shipping). Only the shipping address is required.
Meine erstellte XML:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<purchase-order>
<orderPosition>
<product-name></product-name>
<quantity></quantity>
<price></price>
<comment></comment>
<date type="shipping-date"></date>
</orderPosition>
<date type="order-date"></date>
<comment></comment>
<address type="billing"></address>
<address type="shipping"></address>
</purchase-order>
Meine erstellte DTD:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE purchase-order [
<!ELEMENT purchase-order (order-position, address, date, comment?)+>
<!ELEMENT order-position (product-name, quantity, price, comment?, date?)>
<!ELEMENT product-name (#PCDATA)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT comment (#PCDATA)>
<!ELEMENT shipping-date (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ATTLIST date (order|shipping) #REQUIRED>
<!ELEMENT address (#PCDATA)+>
<!ATTLIST address type (billing|shipping) #REQUIRED>
]>
Der Punkt "can specify different addresses" gepaart mit "Only the shipping address is required" ist mir da ein Dorn im Auge. Weil ich das ja so nicht wirklich validiert habe und ich aber auch nicht wüsste wie, außer tatsächlich zwei komplett verschiedene Adresselemente zu erstellen und billing dann einmal mit einem ? Indikator zu versehen für den optionalen Aspekt.
Dass ich Comment als Element nur einmal haben darf ist richtig oder? Die Anordnung ist soweit ich weiß egal.