Я недавно создал файл XML для проекта вместе с таблицей стилей XSLT для создания простого формата таблицы после загрузки XML в мой веб-браузер. Кроме того, у меня есть веб-сайт HTML, и я хочу иметь возможность взять эту сгенерированную таблицу и поместить ее на веб-страницу HTML, чтобы затем я мог соответствующим образом оформить ее в CSS вместе с остальной частью веб-сайта.
Iу меня есть заданный макет для моего веб-сайта HTML, и я просто хочу переместить таблицу, сгенерированную XML / XSLT, и отобразить ее на странице HTML.
Моя примерная страница XML: XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="PT.xslt"?>
<!DOCTYPE owners [
<!ELEMENT owners (business+)>
<!ELEMENT business (servicetype, businessname, businesslogo*, servicepic+, url, address, phone+, operatinghours, services, description, rating*, averageprice, currentsales*)>
<!ELEMENT servicetype (#PCDATA)>
<!ELEMENT businessname (#PCDATA)>
<!ELEMENT businesslogo (#PCDATA)>
<!ELEMENT servicepic (#PCDATA)>
<!ELEMENT url (#PCDATA)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT operatinghours (#PCDATA)>
<!ELEMENT services (minimumprice, hourlyfee)>
<!ELEMENT minimumprice (#PCDATA)>
<!ELEMENT hourlyfee (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT rating (#PCDATA)>
<!ELEMENT averageprice (#PCDATA)>
<!ELEMENT currentsales (#PCDATA)>
]>
<owners>
<business>
<servicetype>Physical Training </servicetype>
<businessname>Big Guns Fitness </businessname>
<businesslogo>img/logo.jpg</businesslogo>
<servicepic>service1.jpg</servicepic>
<url>www.biggunz.net.au</url>
<address>41 Lekemba Road, Rodstead 2259 NSW Australia </address>
<phone>0483659150</phone>
<operatinghours>0900-1700 Monday-Friday</operatinghours>
<services>
<minimumprice>$49.99</minimumprice>
<hourlyfee>$49.99</hourlyfee>
</services>
<description>At Big Guns Fitness, we strive to deliver the greatest in expertise and professionalism, delivered to you in world class training and design.</description>
<rating>4.9/5.0</rating>
<averageprice>$89.49</averageprice>
<currentsales>First Workout Free (ends 30th Sept 2019)</currentsales>
</business>
<business>
<servicetype>Physical Training </servicetype>
<businessname>Shape Up Bodyworks</businessname>
<businesslogo>img/logo2.jpg</businesslogo>
<servicepic>service2.jpg</servicepic>
<url>www.SUBodyworks.com</url>
<address>987 Wolka St, Harmet 8792 QLD Australia</address>
<phone>0487373203</phone>
<operatinghours>0900-1700 Monday-Thursday, 1000-1700 Friday</operatinghours>
<services>
<minimumprice>$19.99</minimumprice>
<hourlyfee>$39.99</hourlyfee>
</services>
<description>Work hard, fast and the right way. Shape Up Bodyworks is the home of athletes, right in the heart of Peak Physical Training.</description>
<rating>4.2/5.0</rating>
<averageprice>$29.99</averageprice>
<currentsales>Buy two PT sessions, get one half price</currentsales>
</business>
<business>
<servicetype>Physical Training </servicetype>
<businessname>Orion Supplements</businessname>
<businesslogo>img/logo3.jpg</businesslogo>
<servicepic>service3.png</servicepic>
<url>www.OrionSupplements.fitness.au</url>
<address>21 Kendall St, Albourke 2232 NSW Australia</address>
<phone>0429487304</phone>
<operatinghours>0800-1600 Monday-Wednesday, 0900-1700 Thursday-Friday</operatinghours>
<services>
<minimumprice>$9.99</minimumprice>
<hourlyfee>$24.95</hourlyfee>
</services>
<description>Orion Supplements is the pinnacle of Physical Training and development supplements. A mix of pre-workout, and an actual workout. Fitness, just hit a whole nother level</description>
<rating>5.0/5.0</rating>
<averageprice>$22.49</averageprice>
<currentsales>2x 2ltr Pre-workout shakers for $50</currentsales>
</business>
</owners>
Мой XSLT: XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Businesses</title>
</head>
<body>
<table border="1" style="border-collapse:collapse;">
<tr bgcolor="#9acd32">
<th>Business Name</th>
<th>Service Type</th>
<th>Website</th>
<th>Business Logo</th>
<th>Service Picture</th>
<th>Address</th>
<th>Phone</th>
<th>Operating Hours</th>
<th>Minimum Price</th>
<th>Hourly Fee</th>
<th>Average Price</th>
<th>Description</th>
<th>Rating</th>
<th>Current Sales</th>
</tr>
<xsl:for-each select="owners/business">
<tr>
<td><xsl:value-of select="businessname"/></td>
<td><xsl:value-of select="servicetype"/></td>
<td><xsl:value-of select="url"/></td>
<td><img src="img/logo.jpg" width="100" height="100"/></td>
<td><img src="img/service1.jpg" width="250" height="120"/></td>
<td><xsl:value-of select="address"/></td>
<td><xsl:value-of select="phone"/></td>
<td><xsl:value-of select="operatinghours"/></td>
<td><xsl:value-of select="services/minimumprice"/></td>
<td><xsl:value-of select="services/hourlyfee"/></td>
<td><xsl:value-of select="averageprice"/></td>
<td><xsl:value-of select="description"/></td>
<td><xsl:value-of select="rating"/></td>
<td><xsl:value-of select="currentsales"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>