The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
XML Application Development
Â
The example that will be used here will be the translating of measurements, both distance and weight, from one measurement standard to another. The distance measurements will translate from Imperial mile to Metric Kilometer. The weight measurements will translate from Troy Ounce to Metric Gram.
Â
For this, you will produce 4 files:
Â
· measurements1.html
Â
· measurements1.xml
Â
· measurements1.xsd
Â
· measurements1.xslt
Â
You will be creating the xml, xsd, and the xslt files using any text editor you want. The html file will be created for you using the saxon tool.
Â
1. Use the measurements1.xsd file from the previous assignment.
Â
2. Build an XML document based on the schema in measurements1.xsd. Name this document measurements1.xml.
Â
a. This XML document should have a root of measurements.
b. This XML document should have at least 3 child elements to measurements.
Â
3. Provide a XSLT style sheet to display the contents in the measurements1.xml file. Name this file measurements1.xslt.
Â
a. The first template should match the root of the document.
i. Inside the template, provide a html document that outputs the total number of items in the measurements1.xml file and how many of each kind are in the file.
ii. There should also be an apply-templates call that matches the measurement element.
b. The second template should match measurement.
i. In this template, choose between weight and distance based on the attribute typeOfMeasurement
ii. For distanceType, you should output the distance/@measureDistance attribute, as well as the distance element.
iii. For weightType, you should output the weight@measureWeight attribute, as well as the weight element.
Â
4. Run these through the sax processor with the commandÂ
Transform.exe -sa -s:measurements1.xml -xsl:measurements1.xslt -xsd:measurements1.xsd -o:measurements1.html
This should result in an html file that outputs something similar to:
Â
The 3 measurements that I want transformed.
Â
There are 2 distance measurements
Â
There is 1 weight measurement.
Â
A distance measurement using the imperial scale is:
Â
The length of the distance is 1.45
A weight measurement using the troy scale is:
Â
The amount of the weight is .6<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="https://www.w3.org/2001/XMLSchema">
<xs:element name="measurementType" type="xs:string"/>
   <xs:simpleType>
   <xs:restriction base="xs:string">
     <xs:minInclusive value="distanceType"/>
     <xs:maxInclusive value="weightType"/>
   </xs:restriction>
 </xs:simpleType>
 </xs:element>
<xs:element name="disType" type="xs:string"/>
   <xs:simpleType>
   <xs:restriction base="xs:string">
     <xs:minInclusive value="imperial"/>
     <xs:maxInclusive value="metric"/>
   </xs:restriction>
 </xs:simpleType>
</xs:element>
<xs:element name="weiType" type="xs:string"/>
<xs:simpleType>
   <xs:restriction base="xs:string">
     <xs:minInclusive value="troy"/>
     <xs:maxInclusive value="gram"/>
   </xs:restriction>
 </xs:simpleType>
</xs:element>
<xs:element name="measurement" typeOfMeasurement="measurementType">
 <xs:complexType>
   <xs:choice>
     <xs:element name="distance" type="disType"/>
     <xs:element name="weight" type="weiType"/>
   </xs:choice>
 </xs:complexType>
</xs:element>
A distance measurement using the metric scale is:
Â
The length of distance is 25
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly