इसलिए मैंने इसे शोध करने की कोशिश की और मैं लगभग अपने wits 'अंत में हूँ। मुझे XML में एक्सएसएल को dpawson.co.uk, पर एम्बेड करने का एक तरीका मिला, लेकिन मुझे पता नहीं चल रहा कि मैं क्या गलत कर रहा हूं। मैंने समाधान और स्पष्टीकरण खोजने की कोशिश कर इंटरनेट को खराब कर दिया है, लेकिन किसी को भी कोई जवाब नहीं लगता है।वेब ब्राउज़र में प्रदर्शन के लिए एक्सएमएल में एक्सएसएल एम्बेड करें: मैं गलत क्या कर रहा हूं?
मैं एक फ़ाइल बनाने की कोशिश कर रहा हूं जो सर्वर-स्वतंत्र है इसलिए मैं अपने सहयोगियों को एक फ़ाइल भेज सकता हूं ताकि वे इसे अपने वेब ब्राउज़र में खोलकर फ़ाइल देख सकें।
यहाँ मेरी कोड अब तक बताया गया है:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--Start XSL-->
<?xml-stylesheet type="text/xml" href="#stylesheet"?>
<!DOCTYPE doc [
<!ATTLIST xsl:stylesheet
id ID #REQUIRED>
]>
<doc>
<xsl:stylesheet id="stylesheet"
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="xsl:stylesheet" />
<!--Variables-->
<xsl:variable name="a" select="list/movie/seen[@value ='Yes']" />
<xsl:variable name="b" select="list/movie/seen" />
<xsl:variable name="c" select="sum(list/movie/rating/@value)" />
<xsl:variable name="d" select="$c div count($a)" />
<xsl:variable name="e" select="count($a) div count($b)" />
<xsl:variable name="f" select="list/movie/seen[@value ='No']" />
<xsl:variable name="g" select="list/movie/seen[@value ='Prior']" />
<xsl:variable name="h" select="count($f) div count($b)" />
<xsl:variable name="j" select="count($g) div count($b)" />
<xsl:variable name="minutes_total" select="sum(list/movie/length[@value ='y'])" />
<xsl:variable name="minutes" select="$minutes_total mod 60" />
<xsl:variable name="hours" select="floor($minutes_total div 60) mod 24" />
<xsl:variable name="hours2" select="floor($minutes_total div 60)" />
<xsl:variable name="days" select="floor($hours2 div 24)" />
<xsl:decimal-format name="percent" />
<xsl:decimal-format name="average" decimal-separator="." />
<!--End Variables-->
<xsl:template match="/doc">
<html>
<head>
<style>
h2{
font-family: Courier, Courier New, monospace;
font-size: 32px;
text-decoration: underline;
}
body{
font-family: Courier New, monospace;
}
p{
font-size: 16px;
}
table{
font-size: 14px;
}
.title{
text-align:left;
}
.release{
text-align:center;
}
.seen{
text-align:center;
}
.rating{
text-align:right;
}
.length{
text-align:center;
}
</style>
</head>
<body>
<h2>My Movie List</h2>
<p>Movies seen so far: <xsl:value-of select="count($a)" />/<xsl:value-of select="count($b)" /> = <xsl:value-of select="format-number($e, '#%', 'percent')" /><br />
Movies yet to see: <xsl:value-of select="count($f)" />/<xsl:value-of select="count($b)" /> = <xsl:value-of select="format-number($h, '#%', 'percent')" /><br />
Movies seen prior to making list: <xsl:value-of select="count($g)" />/<xsl:value-of select="count($b)" /> = <xsl:value-of select="format-number($j, '#%', 'percent')" /><br />
Total time watched: <xsl:value-of select="format-number($days, '#0')" /> days, <xsl:value-of select="format-number($hours, '#0')" /> hours, <xsl:value-of select="format-number($minutes, '#0')" /> minutes<br />
Average rating: <xsl:value-of select="format-number($d, '#.000', 'average')" /> stars out of 5</p>
<br />
<table border="1">
<tr>
<th>#</th>
<th>Title</th>
<th>Release Date</th>
<th>Length</th>
<th>Seen</th>
<th>Rating</th>
</tr>
<xsl:for-each select="list/movie">
<xsl:choose>
<xsl:when test='seen = "Yes"'>
<tr style="background-color:#666; color:#fff">
<td> <xsl:number /></td>
<td class="title"><xsl:value-of select="title"/></td>
<td class="release"><xsl:value-of select="release"/></td>
<td class="length"><xsl:value-of select="length" /> minutes</td>
<td class="seen"><xsl:value-of select="seen"/></td>
<td class="rating"><xsl:value-of select="rating"/></td>
</tr>
</xsl:when>
<xsl:when test='seen = "Seen prior to making list"'>
<tr style="background-color:#999; color:#000">
<td> <xsl:number /></td>
<td class="title"><xsl:value-of select="title"/></td>
<td class="release"><xsl:value-of select="release"/></td>
<td class="length"><xsl:value-of select="length"/> minutes</td>
<td class="seen"><xsl:value-of select="seen"/></td>
<td class="rating"><xsl:value-of select="rating"/></td>
</tr>
</xsl:when>
<xsl:otherwise>
<tr style="background-color:#fff;">
<td> <xsl:number /></td>
<td class="title"><xsl:value-of select="title"/></td>
<td class="release"><xsl:value-of select="release"/></td>
<td class="length"><xsl:value-of select="length" /> minutes</td>
<td class="seen"><xsl:value-of select="seen"/></td>
<td class="rating"><xsl:value-of select="rating"/></td>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<!--Start XML-->
<list>
<movie>
<title>2001: A Space Odyssey</title>
<release>1968</release>
<seen value="No">No</seen>
<rating>N/A</rating>
<length value="n">141</length>
</movie>
<movie>
<title>28 Days Later</title>
<release>2002</release>
<seen value="No">No</seen>
<rating>N/A</rating>
<length value="n">113</length>
</movie>
<movie>
<title>28 Weeks Later</title>
<release>2007</release>
<seen value="No">No</seen>
<rating>N/A</rating>
<length value="n">100</length>
</movie>
<movie>
<title>A Clockwork Orange</title>
<release>1971</release>
<seen value="Yes">Yes</seen>
<rating value="2">☆☆☆★★</rating>
<length value="y">136</length>
</movie>
<!--Rest of XML-->
</list>
</doc>
यह होता है कि कितने मैं अब तक देखा है फिल्मों की एक सूची, कितने मैं अभी तक है, देखने के लिए कितने मैंने देखा है कि मैंने पहले सूची बनाई, मैंने फिल्मों को देखने में कितना समय लगाया, और प्रति फिल्म औसत रेटिंग देखी गई।
समस्या यह है कि सभी चर शून्य मान के साथ दिखाए जा रहे हैं, जो शून्यों से विभाजित होता है जो कुछ आउटपुट पर भी NaN मान देता है।
कोई भी जो भी पेशकश कर सकता है उसकी सराहना की जाएगी!
मैं वास्तव में समझ नहीं पा रहा हूं कि आप यहां क्या करने की कोशिश कर रहे हैं लेकिन मुझे नहीं लगता कि यह एक स्टाइलशीट है। आपका टैग टैग के भीतर एम्बेड किया गया है जो बहुत अजीब है –
Kevan
दुर्भाग्यवश, मेरा एक्सएमएल पूरी तरह से प्रश्न के मुख्य भाग में फिट होने के लिए बहुत बड़ा था। मैं जो करने की कोशिश कर रहा हूं वह मेरे चर को काम करने के लिए मिलता है। जब मेरे पास .xml और .xsl फ़ाइलें अलग होती हैं, तो यह खूबसूरती से काम करती है। लेकिन जब मैं एम्बेड करता हूं, एक्सएमएल दिखाता है, लेकिन मेरे चर काम नहीं करते हैं। मुझे बहुत सारे 0 और NaNs मिलते हैं। – ishmael624
इस दस्तावेज़ के साथ आप क्या कर रहे हैं। आप कहते हैं "एक्सएमएल दिखाता है"। कहा पे? आप कौन सा सॉफ्टवेयर चला रहे हैं, और कैसे? –