Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//mdpbatxt.xml <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?> <!-

ID: 3800118 • Letter: #

Question

//mdpbatxt.xml

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!--
New Perspectives on XML

Case Problem 2

MDPBA Competition Roster
Author:
Date:   

Filename: mdpba.xml
Supporting Files: mdpba.xsd
-->

<bands>
<band cid="c0001">
<name grade="juvenille">School of Celtic Bagpipes &amp; Drumming</name>
<city>Delafield</city>
<logo source="celtic.png" />
<competition>
<event type="MSR">
<tune>Charlie's Welcome</tune>
<tune>Mrs MacPherson of Inveran</tune>
<tune>Brown Haired Maiden</tune>
</event>
<event type="Medley">
<tune>Rowd's Hornpipe</tune>
</event>
</competition>
</band>
<band cid="c0002">
<name grade="juvenille">Badger Pipes and Drums</name>
<city>Madison</city>
<logo source="badger.png" />
<competition>
<event type="MSR">
<tune>Lord Alexander Kennedy</tune>
<tune>Bob of Fettercairn</tune>
<tune>Brown Haired Maiden</tune>
</event>
<event type="Medley">
<tune>Out of the Air</tune>
</event>
</competition>
</band>
<band cid="c0003">
<name grade="juvenille">Pardeeville School of Piping and Drumming</name>
<city>Pardeeville</city>
<competition>
<event type="MSR">
<tune>Lord Alexander Kennedy</tune>
<tune>Bob of Fettercairn</tune>
<tune>The Little Cascade</tune>
</event>
<event type="Medley">
<tune>The Radar Racketeer</tune>
</event>
</competition>
</band>
<band cid="c0004">
<name grade="1">Zoar Scottish Pipe Band</name>
<city>Zoar</city>
<competition>
<event type="MSR">
<tune>Charlie's Welcome</tune>
<tune>Mrs MacPherson of Inveran</tune>
<tune>Major Manson</tune>
</event>
<event type="Medley">
<tune>Miss Lily</tune>
</event>
</competition>
</band>
<band cid="c0005">
<name grade="novice">Stockholm Pipe Band</name>
<city>Stockholm</city>
<competition>
<event type="MSR">
<tune>Pretty Marion</tune>
<tune>The Sheepwife</tune>
<tune>Brown Haired Maiden</tune>
</event>
<event type="Medley">
<tune>Farewell to Erin</tune>
</event>
</competition>

//mdpbatxt.xsd

<?xml version="1.0" encoding="UTF-8" ?>
<!--
New Perspectives on XML

Case Problem 2

MDPBA schema
Author:
Date:   

Filename: mdpba.xsd
Supporting Files: mdpba.xml

-->

1. Using your XML editor, open the mdpbatxt.xml and mdpbatxt.xsd files from the xmlo3 case2 folder, enter your name and today's date in the comment section ofeach file, and then save the files as mdpba.xml and mdpba.xsd, respectively. 2. Go to the mopba.xsd file in your text editor. Add the root schema element to the document and declare the XML Schema namespace using the xe prefix 3. Atach the schema file mdpba.xsd to the instance document, indicating that the sohema and instance document do not belong to any namespace. Tutorial 3 Valldating Documents with Schemas IXML 4. Create the following named simple types: a. gradeType, based on the etring data type and limited to the enumerated values novic juvenile, 2, 3, and 4 b. eType, based on the string data type and limited to the enumerated values MsR and Mediey elarype, based on the ID data type and restricted to the regular expression pattern cva(4) d. nroType, based on the string data type and restricted to the regular expression pattern a-ZA-20-91 -png 5. Declare the bands element containing the child element band.The band element must occur at least once, but its upper limit is unbounded. 6. Declare the and element containing the following sequence of nested dild elements name, city, logo, and compet1t1on. Set the following properties for the nested elements: a. All of the child elements should contain string data. The name element should also support the required grade attribute. b. The logo element is optional. The band element must contain the cla attribute, 7. Declare the aogo element, which has no content and contains the required attribute source. 8. Declare the competit1on element containing the dhild element event. The event element must occur at least once, but its upper limit is unbounded. 9. Declare the event element containing the dildelement tune. The tune element must occur at least once, but its upper limit is unbounded. The event element is required. 10. Declare the following attributes and elements: a. The attribute grade, which uses the gradeType data type b. The attribute type, which uses the eType data type The attri ute cla, which uses the clarype data type d. The attribute source, which uses the srcType data type The element city, which uses the string data type f. The element tune, which uses the string data type 11. Save your changes to the mdpba.xsd file, and then validate the schema. Continue to correct any validation errors you discover until the schema validates. 12. Validate the mdpba.xml file against the schema. Continue to correct any validation errors you discover until the instance document validates, XML 189

Explanation / Answer

logo element:

Elements elements = doc.getElementsByTag("img");
for (Element element : elements) {

//Searching the src tag inside img tag
logo =element.attr("src");
String logo1=logo;

//If src link has substring logo
if(logo1.toLowerCase().contains("logo")|| element.attr("alt").toLowerCase().contains("logo"))
{
if(!logo.contains("http"))
{
if(!logo.startsWith("/"))
logo=link + "/"+logo;
else
logo=link+logo;
}
System.out.println(logo);
logoflag=1;

}
       }