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

THIS FILE SAVED AS \"Nutrition.xml\" <?xml version = \"1.0\" encoding=\"utf-8\"?

ID: 3669339 • Letter: T

Question

THIS FILE SAVED AS "Nutrition.xml"

<?xml version = "1.0" encoding="utf-8"?>

<schema xmlns = "http://www.w3.org/2001/XMLSchema"
       xmlns:food = "http://www.deitel.com/food"
       targetNamespace = "http://www.deitel.com/food">
<element name = "product" type = "food:ProductType"/>
<complexType name = "ProductType">
<all>
<element name = "name" type = "string"/>
<element name = "nutrition" type = "food:NutritionType"/>
</all>
</complexType>
<complexType name = "NutritionType">
<sequence>
<element name = "fact" type = "food:FactType"
               minOccurs = "0" maxOccurs = "unbounded"/>
</sequence>
</complexType>
<complexType name = "FactType">
<all>
<element name = "quantity" type = "food:QuantityType"/>
</all>
<attribute name = "name" type = "string"/>
</complexType>
<complexType name = "QuantityType">
<simpleContent>
<extension base = "int">
<attribute name = "unit" type = "string"/>
</extension>
</simpleContent>
</complexType>
</schema>

WRITE AN XSL STYLE SHEET FOR THE ABOVE CODE THAT DISPLAYS THE NUTRITIONAL FACTS IN AN HTML5 TABLE.

Explanation / Answer

@using System.Globalization @model IEnumerable @{ ViewBag.Title = "Home Page"; } function loadXMLDoc(filename) { var xhttp = new XMLHttpRequest(); var serverDir = '@Server.MapPath("~/App_Data/").Replace(@"", @"\")'; xhttp.open("GET", serverDir + filename, false); xhttp.send(""); return xhttp.responseXML; } function xslTransform(transformer, xml) { var xsl = loadXMLDoc(transformer); var xsltProcessor = new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); return xsltProcessor.transformToFragment(xml, document); } function displayNutritionFact(factId, ingredientQuantity, ingredientUnits) { $.ajax({ url: "@Url.Action("LoadNutritionFactHtml")", type: "GET", data: { factId: factId, quantity: ingredientQuantity, units: ingredientUnits }, success: function (xhtml) { $('#nutritionFactContent').html(xhtml); $('#nutritionFactModal').modal(); } }); } $(function () { $('.ingredients').click(function () { var nutritionFactRecipePair = $(this).attr('id').substring("ingredient_".length); var ingredientQuantity = $('#iQty_' + nutritionFactRecipePair).html().replace(',', '.'); var ingredientUnits = $('#iUnits_' + nutritionFactRecipePair).html(); var nutritionFactId = nutritionFactRecipePair.split("-")[0]; displayNutritionFact(nutritionFactId, ingredientQuantity, ingredientUnits); }); $('.summary').click(function() { var recipeId = $(this).attr('id').substring("summary_".length); $.ajax({ url: "@Url.Action("LoadRecipeSummaryHtml")", type: "GET", data: { recipeId: recipeId }, success: function (xhtml) { $('#nutritionFactContent').html(xhtml); $('#nutritionFactModal').modal(); } }); }); $('.edit').click(function() { var recipeId = $(this).attr('id').substring("edit_".length); window.location = "@Url.Action("Edit", "Recipes")/" + recipeId; }); $('.delete').click(function() { var recipeId = $(this).attr('id').substring("delete_".length); window.location = "@Url.Action("Delete", "Recipes")/" + recipeId; }); $('.downloadRecipe').click(function() { var recipeId = $(this).attr('id').substring("download_".length); window.location = "@Url.Action("DownloadRecipePdf")?recipeId=" + recipeId; }); }); @foreach (var recipe in Model) { var recipeId = recipe.id;

@Html.DisplayFor(modelItem => recipe.title)

Edit Delete Nutritional values Pdf

Servings

Makes @recipe.portions servings.

Preparation time

@recipe.preparationTime.time @recipe.preparationTime.units

Ingredients

@foreach (var ingredient in recipe.ingredients) {

@Html.DisplayFor(modelItem => ingredient.name)

@ingredient.quantity  @ingredient.units

}

Method

@foreach (var section in recipe.content) {

@Html.DisplayFor(modelItem => section.name)

@Html.DisplayFor(modelItem => section.SectionText)

} } Close