Generare xsd da un file xml

venerdì 18 settembre 2009 - 10.13

sirousblack Profilo | Newbie

Buongiorno ragazzi, sono nuovo all'uso dell'xml ed ho la necessità di creare un ssis su visual studio 2005 che mi permetta innanzitutto di importare un file xml tramite un flusso dati la cui fonte sara' ovviamente un "origine xml". E qui subito si presenta il problema perche' io ho a disposizione solamente il file xml mentre nelle proprieta' dell'l'origine xml viene richiesto il percorso del file xml e va bene, poi se e' un file xml con struttura inline sarei a posto ma non lo e', quindi sono obbligato a specificare anche il percorso del file struttura xsd che non ho. Ho provato a ricavarlo dal file xml ma senza successo perche' poi quando provo ad usarlo mi ritorna svariati errori di formattazione. QUesto e' un esempio di file xml che devo importare:

<?xml version="1.0" ?>
- <OrderResponse>
- <OrderResponseHead>
- <Schema>
<Version>3.04</Version>
</Schema>
- <Parameters>
<Language>en-GB</Language>
<DecimalSeparator>.</DecimalSeparator>
<Precision>20.2</Precision>
</Parameters>
<OrderResponseType Code="ACK">Full Acknowledgement</OrderResponseType>
- <OrderCurrency>
<Currency Code="EUR">Euros</Currency>
</OrderCurrency>
<Checksum />
</OrderResponseHead>
- <OrderResponseReferences>
<BuyersOrderNumber Preserve="true">A_2000 000001</BuyersOrderNumber>
<SuppliersOrderReference Preserve="true">3500000</SuppliersOrderReference>
<CrossReference>029</CrossReference>
</OrderResponseReferences>
- <BOSS:AdditionalOrderResponseReferences xmlns:BOSS="urn:schemas-bossfed-co-uk:OP-OrderResponse-v1">
- <BOSS:OrderResponseReference ReferenceType="OTP" ReferenceDesc="Order Type">
<BOSS:Reference>D</BOSS:Reference>
</BOSS:OrderResponseReference>
</BOSS:AdditionalOrderResponseReferences>
<OrderResponseDate>2009-01-01</OrderResponseDate>
<OriginalOrderDate>2009-01-01</OriginalOrderDate>
- <Supplier>
- <SupplierReferences>
<BuyersCodeForSupplier>.</BuyersCodeForSupplier>
</SupplierReferences>
<Party>.</Party>
</Supplier>
- <Buyer>
- <BuyerReferences>
<SuppliersCodeForBuyer>IT5000000IT</SuppliersCodeForBuyer>
</BuyerReferences>
<Party>Azienda Srl</Party>
- <Address>
<AddressLine>VIA Industriale 7</AddressLine>
<AddressLine>.</AddressLine>
<AddressLine>FI</AddressLine>
<AddressLine>FIRENZE</AddressLine>
<PostCode>50100</PostCode>
</Address>
</Buyer>
- <Delivery>
- <DeliverTo>
<Party>Azienda Srl</Party>
- <Address>
<AddressLine>VIA Industriale 8</AddressLine>
<AddressLine>.</AddressLine>
<AddressLine>FI</AddressLine>
<AddressLine>Firenze</AddressLine>
<PostCode>50100</PostCode>
</Address>
</DeliverTo>
- <DeliverFrom>
- <DeliverFromReferences>
<SuppliersCodeForLocation>P00</SuppliersCodeForLocation>
</DeliverFromReferences>
<Party>.</Party>
</DeliverFrom>
<SpecialInstructions>OP=N</SpecialInstructions>
</Delivery>
- <OrderResponseLine>
<LineNumber>1</LineNumber>
- <Product>
<SuppliersProductCode>600000</SuppliersProductCode>
</Product>
- <Quantity>
<Amount>1</Amount>
</Quantity>
<LineTotal>10.10</LineTotal>
- <Delivery>
- <Quantity>
<Amount>1</Amount>
</Quantity>
<DeliveryInformation>LS</DeliveryInformation>
</Delivery>
- <Delivery>
- <Quantity>
<Amount>0</Amount>
</Quantity>
<DeliveryInformation>LB</DeliveryInformation>
</Delivery>
<Narrative />
</OrderResponseLine>
- <OrderResponseLine>
<LineNumber>2</LineNumber>
- <Product>
<SuppliersProductCode>090000</SuppliersProductCode>
</Product>
- <Quantity>
<Amount>5</Amount>
</Quantity>
<LineTotal>50.10</LineTotal>
- <Delivery>
- <Quantity>
<Amount>5</Amount>
</Quantity>
<DeliveryInformation>LS</DeliveryInformation>
</Delivery>
- <Delivery>
- <Quantity>
<Amount>0</Amount>
</Quantity>
<DeliveryInformation>LB</DeliveryInformation>
</Delivery>
<Narrative />
</OrderResponseLine>
- <OrderResponseLine>
<LineNumber>3</LineNumber>
- <Product>
<SuppliersProductCode>370000</SuppliersProductCode>
</Product>
- <Quantity>
<Amount>24</Amount>
</Quantity>
<LineTotal>40.40</LineTotal>
- <Delivery>
- <Quantity>
<Amount>24</Amount>
</Quantity>
<DeliveryInformation>LS</DeliveryInformation>
</Delivery>
- <Delivery>
- <Quantity>
<Amount>0</Amount>
</Quantity>
<DeliveryInformation>LB</DeliveryInformation>
</Delivery>
<Narrative />
</OrderResponseLine>
- <OrderResponseTotal>
<FreightCharges>0.00</FreightCharges>
<MiscCharges>0.00</MiscCharges>
</OrderResponseTotal>
</OrderResponse>

Datemi una dritta perche' sono nel buio totale.

alx_81 Profilo | Guru

>Buongiorno ragazzi
Ciao

>Datemi una dritta perche' sono nel buio totale.
Il file xsd lo puoi creare da Visual Studio. Carica il file XML e poi nella voce XML, appunto, clicka su Generate XSD Schema.. o qualcosa di simile
Questo crea da un XML well formed il suo xsd o meglio, il più vicino, che tu puoi dettagliare ulteriormente, se ritieni necessario.

--

Alessandro Alpi | SQL Server MVP

http://www.alessandroalpi.net
http://blogs.dotnethell.it/suxstellino
http://mvp.support.microsoft.com/profile/Alessandro.Alpi
http://italy.mvps.org
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5