xmlhack.ru logo
>> статьи на xmlhack.ru

Примеры к статье «Канонизация XML (Часть 2)»

В закладки:   Del.icio.us   reddit

Предварительные замечания

Некоторые строки примеров слишком длинны чтобы уместиться на одном экране. В этом случае мы разбиваем длинные строки на более мелкие и в точках разрыва ставим знак ▒.

Статья «Канонизация XML (Часть 2)».

Листинг 1

<?xml version="1.0"?>
<?xml-stylesheet   href="http:/www.myFictitiosCompany.com/style-sheet.x▒
sl"   type="text/xsl"   ?>
<!DOCTYPE product [
<!ATTLIST part approved CDATA "yes">
<!ENTITY testhistory SYSTEM "http:/www.myFictitiosCompany.com/testhisto▒
ry.txt">
]>
<!-- We assume that the file referenced by the "testhistory" external e▒
ntity contains the following string:

Part has been tested according to the specified standards.

-->
<product xmlns="http://www.myFictitiousCompany.com/product"
      xmlns:sup="http://www.myFictitiousCompany.com/supplier"
      name='rotating disc "Energymeter"'
      id="P 184.435"
      classification = "MeasuringInstruments/Electrical/Energy/">
  <parts>
    <part id="P184.675"
       name="bearing">
      <sup:supplier id="S1753"/>
      <sup:supplier id="S2341"/>
      <sup:supplier id="S3276"/>
      <comments>&testhistory;</comments>
    </part>
    <part id="P184.871"
       name="magnet"
       xmlns="http://www.myFictitiousCompany.com/product">
      <sup:supplier id="S3908"/>
      <sup:supplier id="S4589"/>
      <sup:supplier id="S1098"/>
      <comments>&testhistory;</comments>
    </part>
<![CDATA[Price of part P184.675 < price of part P184.871]]>
  </parts>
</product>

Листинг 2

<?xml version="1.0"?>
<?xml-stylesheet   href="http:/www.myFictitiosCompany.com/style-sheet.x▒
sl"   type="text/xsl"   ?>
<!DOCTYPE product [
<!ATTLIST part approved CDATA "yes">
<!ENTITY testhistory SYSTEM "http:/www.myFictitiosCompany.com/testhisto▒
ry.txt">
]>
<!-- We assume that the file referenced by the "testhistory" external e▒
ntity contains the following string: 
 
Part has been tested according to the specified standards.

-->
<product xmlns="http://www.myFictitiousCompany.com/product"
       xmlns:sup="http://www.myFictitiousCompany.com/supplier" 
       name='rotating disc "Energymeter"'
       id="P 184.435"
       classification = "MeasuringInstruments/Electrical/Energy/">
  <parts>
    <part id="P 184.675"
       name="bearing">
      <sup:supplier id="S 1753"/>
      <sup:supplier id="S 2341"/>
      <sup:supplier id="S 3276"/>
      <comments>&testhistory;</comments>
    </part>
    <part id="P184.871"
       name="magnet"
       xmlns="http://www.myFictitiousCompany.com/product">
      <sup:supplier id="S 3908"/>
      <sup:supplier id="S 4589"/>
      <sup:supplier id="S 1098"/>
      <comments>&testhistory;</comments>
    </part>
Price of part P184.675 < price of part P184.871
  </parts>
</product>

Листинг 3

<?xml version="1.0"?>
<?xml-stylesheet href="http:/www.myFictitiosCompany.com/style-sheet.xsl▒
"   type="text/xsl"   ?>
<!DOCTYPE product [
<!ATTLIST part approved CDATA "yes">
<!ENTITY testhistory SYSTEM "http:/www.myFictitiosCompany.com/testhisto▒
ry.txt">
]>
<!-- We assume that the file referenced by the "testhistory" external e▒
ntity contains the following string: 
 
Part has been tested according to the specified standards.

-->
<product xmlns="http://www.myFictitiousCompany.com/product"
      xmlns:sup="http://www.myFictitiousCompany.com/supplier" 
      name='rotating disc "Energymeter"'
      id="P 184.435"
      classification = "MeasuringInstruments/Electrical/Energy/">
  <parts>
    <part id="P 184.675"
       name="bearing">
      <sup:supplier id="S 1753"/>
      <sup:supplier id="S 2341"/>
      <sup:supplier id="S 3276"/>
      <comments>&testhistory;>/comments>
    </part>
    <part id="P 184.871"
       name="magnet"
       xmlns="http://www.myFictitiousCompany.com/product">
      <sup:supplier id="S 3908"/>
      <sup:supplier id="S 4589"/>
      <sup:supplier id="S 1098"/>
      <comments>&testhistory;</comments>
    </part>
Price of part P184.675 < price of part P184.871
  </parts>
</product>

Листинг 4

<?xml version="1.0"?>
<?xml-stylesheet href="http:/www.myFictitiosCompany.com/style-sheet.xsl▒
"   type="text/xsl"   ?>
<!DOCTYPE product [
<!ATTLIST part approved CDATA "yes">
<!ENTITY testhistory SYSTEM "http:/www.myFictitiosCompany.com/testhisto▒
ry.txt">
]>
<!-- We assume that the file referenced by the "testhistory" external e▒
ntity contains the following string: 
 
Part has been tested according to the specified standards.

-->
<product xmlns="http://www.myFictitiousCompany.com/product"
      xmlns:sup="http://www.myFictitiousCompany.com/supplier" 
      name='rotating disc "Energymeter"'
      id="P 184.435"
      classification = "MeasuringInstruments/Electrical/Energy/">
  <parts>
    <part id="P 184.675"
       name="bearing">
      <sup:supplier id="S 1753"/>
      <sup:supplier id="S 2341"/>
      <sup:supplier id="S 3276"/>
      <comments>Part has been tested according to the specified standar▒
ds.</comments>
    </part>
    <part id="P 184.871"
       name="magnet"
       xmlns="http://www.myFictitiousCompany.com/product">
      <sup:supplier id="S 3908"/>
      <sup:supplier id="S 4589"/>
      <sup:supplier id="S 1098"/>
      <comments>Part has been tested according to the specified standar▒
ds.</comments>
    </part>
Price of part P184.675 < price of part P184.871
  </parts>
</product>

Листинг 5

<?xml version="1.0"?>
<?xml-stylesheet href="http:/www.myFictitiosCompany.com/style-sheet.xsl▒
"   type="text/xsl"   ?>
<!DOCTYPE product [
<!ATTLIST part approved CDATA "yes">
<!ENTITY testhistory SYSTEM "http:/www.myFictitiosCompany.com/testhisto▒
ry.txt">
]>
<product xmlns="http://www.myFictitiousCompany.com/product"
      xmlns:sup="http://www.myFictitiousCompany.com/supplier" 
      name='rotating disc "Energymeter"'
      id="P 184.435"
      classification = "MeasuringInstruments/Electrical/Energy/">
  <parts>
    <part id="P 184.675"
       name="bearing">
      <sup:supplier id="S 1753"/>
      <sup:supplier id="S 2341"/>
      <sup:supplier id="S 3276"/>
      <comments>Part has been tested according to the specified standar▒
ds.</comments>
    </part>
    <part id="P 184.871"
       name="magnet"
       xmlns="http://www.myFictitiousCompany.com/product">
      <sup:supplier id="S 3908"/>
      <sup:supplier id="S 4589"/>
      <sup:supplier id="S 1098"/>
      <comments>Part has been tested according to the specified standar▒
ds.</comments>
    </part>
Price of part P184.675 < price of part P184.871
  </parts>
</product>

Листинг 6

<?xml-stylesheet href="http:/www.myFictitiosCompany.com/style-sheet.xsl▒
"   type="text/xsl"   ?>
<product xmlns="http://www.myFictitiousCompany.com/product" xmlns:sup="▒
http://www.myFictitiousCompany.com/supplier" classification="MeasuringI▒
nstruments/Electrical/Energy/" id="P 184.435" name="rotating disc "Ener▒
gymeter"">
  <parts>
    <part approved="yes" id="P 184.675" name="bearing">
      <sup:supplier id="S 1753"></sup:supplier>
      <sup:supplier id="S 2341"></sup:supplier>
      <sup:supplier id="S 3276"></sup:supplier>
      <comments>Part has been tested according to the specified standar▒
ds.</comments>
    </part>
    <part approved="yes" id="P 184.871" name="magnet">
      <sup:supplier id="S 3908"></sup:supplier>
      <sup:supplier id="S 4589"></sup:supplier>
      <sup:supplier id="S 1098"></sup:supplier>
      <comments>Part has been tested according to the specified standar▒
ds.</comments>
    </part>
Price of part P184.675 < price of part P184.871
  </parts>
</product>

Листинг 7

<?xml version="1.0"?>
<SOAP:Envelope xmlns:SOAP="http://www.w3.org/2001/12/soap-envelope">
  <SOAP:Header>

        <!--Protocol specific information, such as signature etc.-->

  </SOAP:Header>
  <SOAP:Body >
    <bs:PackageBooking
      xmlns:bs="http://www.FictitiousTourismInterface/BookingService"
      xmlns:hs="http://www.FictitiousTourismInterface/HotelService"
      xmlns:cs="http://www.FictitiousTourismInterface/CarRentalService"
      xml:lang="en"        Id='VacationTours/Packages[@id=435]/booking[▒
(@date="2002-09-23T09:06:00Z")and(@number="786")]'
      issueDate="2002-09-23T09:06:00Z">

       <bs:booking unitCharge="50" 
           unitDescription="per night" 
           units="2"
           currency="USD"
           status="confirmed"   >
        <item>
         <hs:room hotelName="White Palace" 
             type="suite"
             bookedFrom="2002-10-12T12:00:00Z"
             bookedTo="2002-10-14T12:00:00Z"  />
       </item> 
      </bs:booking>

       <bs:booking unitCharge="60"
           unitDescription="per night"
           units="1"
           currency="USD"
           status="confirmed">
        <item>
         <hs:room hotelName="Lake View"
             type="suite"
             bookedFrom="2002-10-14T12:00:00Z"
             bookedTo="2002-10-15T12:00:00Z"    />
       </item> 
      </bs:booking>

      <bs:booking unitCharge="200"
           unitDescription="per day"
           units="3"
           currency="USD"
           status="confirmed">
        <item>
         <cs:car make="Toyota"
                           type="Hiace" 
                           bookedFrom="2002-10-12T12:00:00Z"
                           bookedTo="2002-10-15T12:00:00Z"/>
        </item> 
      </bs:booking>

    </bs:PackageBooking>
  </SOAP:Body>
</SOAP:Envelope>

Листинг 8

<bs:booking unitCharge="50"
  unitDescription="per night"
  units="2"
  currency="USD"
  status="confirmed" >
  <item>
    <hs:room hotelName="White Palace"
      type="suite"
      bookedFrom="2002-10-12T12:00:00Z"
      bookedTo="2002-10-14T12:00:00Z"  />
  </item>
</bs:booking>

Листинг 9

<bs:booking xmlns:bs="http://www.FictitiousTourismInterface/BookingServ▒
ice" xmlns:cs="http://www.FictitiousTourismInterface/CarRentalService" ▒
xmlns:hs="http://www.FictitiousTourismInterface/HotelService" xmlns:SOA▒
P="http://www.w3.org/2001/12/soap-envelope" currency="USD" status="conf▒
irmed" unitCharge="50" unitDescription="per night" units="2" xml:lang="▒
en"><item><hs:room bookedFrom="2002-10-12T12:00:00Z" bookedTo="2002-10-▒
14T12:00:00Z" hotelName="White Palace" type="suite"></hs:room></item></▒
bs:booking>

Листинг 10

<?xml version="1.0"?>
<SOAP:Envelope xmlns:SOAP="http://www.w3.org/2001/12/soap-envelope">
  <SOAP:Header>

        <!--Protocol specific information, such as signature etc.-->

  </SOAP:Header>
  <SOAP:Body 
    xmlns:bs="http://www.FictitiousTourismInterface/BookingService"
    xmlns:hs="http://www.FictitiousTourismInterface/HotelService">
    <bs:booking unitCharge="50" 
        unitDescription="per night" 
        units="2"
        currency="USD"
        status="confirmed"   >
    <item>
      <hs:room hotelName="White Palace" 
          type="suite"
          bookedFrom="2002-10-12T12:00:00Z"
          bookedTo="2002-10-14T12:00:00Z"  />
    </item> 
    </bs:booking>

  </SOAP:Body>
</SOAP:Envelope>

Листинг 11

<bs:booking xmlns:bs="http://www.FictitiousTourismInterface/BookingServ▒
ice"  xmlns:hs="http://www.FictitiousTourismInterface/HotelService" xml▒
ns:SOAP="http://www.w3.org/2001/12/soap-envelope" currency="USD" status▒
="confirmed" unitCharge="50" unitDescription="per night" units="2"><ite▒
m><hs:room bookedFrom="2002-10-12T12:00:00Z" bookedTo="2002-10-14T12:00▒
:00Z" hotelName="White Palace" type="suite"></hs:room></item></bs:booki▒
ng>

Листинг 12

<bs:booking xmlns:bs="http://www.FictitiousTourismInterface/BookingServ▒
ice" currency="USD" status="confirmed" unitCharge="50" unitDescription=▒
"per night" units="2"><item><hs:room xmlns:hs="http://www.FictitiousTou▒
rismInterface/HotelService" bookedFrom="2002-10-12T12:00:00Z" bookedTo=▒
"2002-10-14T12:00:00Z" hotelName="White Palace" type="suite"></hs:room>▒
</item></bs:booking>