f0/\/2!3
13-05-2004, 11:38
Salve,
ho un problema: dovrei creare un file xdr (lo schema xml della microsoft) ma non riesco a dargli una specie di condizione if: mi spiego meglio, questo è il codice da cui devo ricavare lo schema...
<?xml version="1.0"?>
<!-- Esercizio 7.4 : eserc7_4.xml -->
<products xmlns="x-schema:[...]>
<product id="p12" perishable="yes">
<name>Ice cream</name>
<manufacturer>xsz Co.</manufacturer>
<quantity>25</quantity>
<price>2</price>
<food>
<nutrition>
<calcium>10.30</calcium>
<proteins>35.5</proteins>
<fat>10</fat>
</nutrition>
<expirationDate>2000-09-12</expirationDate>
</food>
</product>
<product id="p13" perishable="no">
<name>AA Battries</name>
<manufacturer>DCells</manufacturer>
<quantity>100</quantity>
<price>4</price>
<stock>
<warehouse id="w12">
xsz warehouse
<mag>25000</mag>
</warehouse>
<warehouse id="w13">
rza warehouse
<mag>5000</mag>
</warehouse>
</stock>
</product>
</products>
Il problema sta nel fatto che io dovrei richiamare l'elemento food (stock) in caso il product sia perishable (notperishable)... come posso dargli questa condizione?
<?xml version="1.0" encoding="UTF-8"?>
<Schema xmlns[...]>
<ElementType name="products" content="eltOnly" model="closed">
<element type="product" minOccurs="0" maxOccurs="*">
</element>
</ElementType>
<ElementType name="product" content="eltOnly" order="seq" model="closed">
<AttributeType name="id" dt:type="id" required="yes"/>
<AttributeType name="perishable" dt:values="yes no"/>
<attribute type="perishable"/>
<attribute type="id"/>
<element type="name"/>
<element type="manufacturer"/>
<element type="quantity"/>
<element type="price"/>
<element type="food" minOccurs="0" maxOccurs="1"/>
<element type="stock" minOccurs="0" maxOccurs="1"/>
</ElementType>
<ElementType name="name" content="textOnly" model="closed" dt:type="string"/>
<ElementType name="manufacturer" content="textOnly" model="closed" dt:type="string"/>
<ElementType name="quantity" content="textOnly" model="closed" dt:type="int"/>
<ElementType name="price" content="textOnly" model="closed" dt:type="float"/>
<ElementType name="food" content="mixed" model="open">
<element type="nutrition"/>
<element type="expirationDate"/>
</ElementType>
<ElementType name="nutrition" content="eltOnly" order="seq" model="closed">
<element type="calcium"/>
<element type="proteins"/>
<element type="fat"/>
</ElementType>
<ElementType name="calcium" content="textOnly" model="closed" dt:type="float"/>
<ElementType name="proteins" content="textOnly" model="closed" dt:type="float"/>
<ElementType name="fat" content="textOnly" model="closed" dt:type="int"/>
<ElementType name="expirationDate" content="textOnly" model="closed" dt:type="date"/>
<ElementType name="stock" content="mixed" model="closed">
<element type="warehouse" minOccurs="0" maxOccurs="*"/>
</ElementType>
<ElementType name="warehouse" content="mixed" model="closed" order="seq">
<AttributeType name="id" dt:type="id" required="yes"/>
<attribute type="id"/>
<element type="mag"/>
</ElementType>
<ElementType name="mag" dt:type="int" content="textOnly" model="closed"/>
</Schema>
Ho già scritto il resto dello schema ma non riesco a terminarlo per questo problema!!!!
Grazie dell'aiuto! :)
ho un problema: dovrei creare un file xdr (lo schema xml della microsoft) ma non riesco a dargli una specie di condizione if: mi spiego meglio, questo è il codice da cui devo ricavare lo schema...
<?xml version="1.0"?>
<!-- Esercizio 7.4 : eserc7_4.xml -->
<products xmlns="x-schema:[...]>
<product id="p12" perishable="yes">
<name>Ice cream</name>
<manufacturer>xsz Co.</manufacturer>
<quantity>25</quantity>
<price>2</price>
<food>
<nutrition>
<calcium>10.30</calcium>
<proteins>35.5</proteins>
<fat>10</fat>
</nutrition>
<expirationDate>2000-09-12</expirationDate>
</food>
</product>
<product id="p13" perishable="no">
<name>AA Battries</name>
<manufacturer>DCells</manufacturer>
<quantity>100</quantity>
<price>4</price>
<stock>
<warehouse id="w12">
xsz warehouse
<mag>25000</mag>
</warehouse>
<warehouse id="w13">
rza warehouse
<mag>5000</mag>
</warehouse>
</stock>
</product>
</products>
Il problema sta nel fatto che io dovrei richiamare l'elemento food (stock) in caso il product sia perishable (notperishable)... come posso dargli questa condizione?
<?xml version="1.0" encoding="UTF-8"?>
<Schema xmlns[...]>
<ElementType name="products" content="eltOnly" model="closed">
<element type="product" minOccurs="0" maxOccurs="*">
</element>
</ElementType>
<ElementType name="product" content="eltOnly" order="seq" model="closed">
<AttributeType name="id" dt:type="id" required="yes"/>
<AttributeType name="perishable" dt:values="yes no"/>
<attribute type="perishable"/>
<attribute type="id"/>
<element type="name"/>
<element type="manufacturer"/>
<element type="quantity"/>
<element type="price"/>
<element type="food" minOccurs="0" maxOccurs="1"/>
<element type="stock" minOccurs="0" maxOccurs="1"/>
</ElementType>
<ElementType name="name" content="textOnly" model="closed" dt:type="string"/>
<ElementType name="manufacturer" content="textOnly" model="closed" dt:type="string"/>
<ElementType name="quantity" content="textOnly" model="closed" dt:type="int"/>
<ElementType name="price" content="textOnly" model="closed" dt:type="float"/>
<ElementType name="food" content="mixed" model="open">
<element type="nutrition"/>
<element type="expirationDate"/>
</ElementType>
<ElementType name="nutrition" content="eltOnly" order="seq" model="closed">
<element type="calcium"/>
<element type="proteins"/>
<element type="fat"/>
</ElementType>
<ElementType name="calcium" content="textOnly" model="closed" dt:type="float"/>
<ElementType name="proteins" content="textOnly" model="closed" dt:type="float"/>
<ElementType name="fat" content="textOnly" model="closed" dt:type="int"/>
<ElementType name="expirationDate" content="textOnly" model="closed" dt:type="date"/>
<ElementType name="stock" content="mixed" model="closed">
<element type="warehouse" minOccurs="0" maxOccurs="*"/>
</ElementType>
<ElementType name="warehouse" content="mixed" model="closed" order="seq">
<AttributeType name="id" dt:type="id" required="yes"/>
<attribute type="id"/>
<element type="mag"/>
</ElementType>
<ElementType name="mag" dt:type="int" content="textOnly" model="closed"/>
</Schema>
Ho già scritto il resto dello schema ma non riesco a terminarlo per questo problema!!!!
Grazie dell'aiuto! :)