Salve a tutti,
sono nuovo del forum e sono un newbie di xml Schema per cui vi chiedo di perdonare la domanda sciocca che sto per fare ma ho bisogno di capire alcune cose.
Ho due files nella medesima directory:
note.xml
<?xml version="1.0"?>
<note xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="note.xsd">
<to></to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
e note.xsd
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string" default="No name"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Quando visualizzo il file xml nel browser, avendo impostato il parametro default dell'elemento "to" uguale a "No name", mi aspetteri di veder stampato a video una cosa tipo:
<?xml version="1.0"?>
<note xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="note.xsd">
<to>No name</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
ma ottengo solo un <to/>
Cosa sbaglio?
Forse il file xsd non ha effetto direttamente sul file xml? Forse sbaglio qualcosa a livello di namespaces?
Grazie in anticipo

Rispondi quotando