help with xsl

wxdqz

New Member
Could anyone tell me why this stylesheet doesn't pull any of the data from the XML file? The XML file validates against the schema, which I've also included. I'd really appreciate any help.

Does it have something to do with the namespace declarations?

Thanks

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v4.0.1 U (<!-- m --><a class="postlink" href="http://www.xmlspy.com">http://www.xmlspy.com</a><!-- m -->) by Alexander Pilz (private) -->
<fastener xmlns="http://my-company.com/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my-company.com/namespace
FastenerSchema.xsd">
<table table_number="1" bolt_material="ALLOY-STEEL" bolt_head="COUNTERSUNK" joint_material="7150-T651" bolt_applicability="List 1">
<table_row>
<row_id>1</row_id>
<thickness>0</thickness>
<dia_3b>0</dia_3b>
<dia_4b>0</dia_4b>
<dia_5b>0</dia_5b>
<dia_6b>0</dia_6b>
<dia_7b>0</dia_7b>
<dia_8b>0</dia_8b>
<dia_9b>0</dia_9b>
<dia_10b>0</dia_10b>
<dia_12b>0</dia_12b>
<dia_14b>0</dia_14b>
<dia_16b>0</dia_16b>
</table_row>
<table_row>
<row_id>2</row_id>
<thickness>300</thickness>
<dia_3b>450</dia_3b>
<dia_4b>1075</dia_4b>
<dia_5b>1806.25</dia_5b>
<dia_6b>2606.25</dia_6b>
<dia_7b>3375</dia_7b>
<dia_8b>4145</dia_8b>
<dia_9b>4912.5</dia_9b>
<dia_10b>5606.25</dia_10b>
<dia_12b>6215.625</dia_12b>
<dia_14b>7750</dia_14b>
<dia_16b>8287.5</dia_16b>
</table_row>
<table_row>
<row_id>3</row_id>
<thickness>3</thickness>
<dia_3b>900</dia_3b>
<dia_4b>1290</dia_4b>
<dia_5b>1567.5</dia_5b>
<dia_6b>1927.5</dia_6b>
<dia_7b>2250</dia_7b>
<dia_8b>2574</dia_8b>
<dia_9b>2895</dia_9b>
<dia_10b>3127.5</dia_10b>
<dia_12b>3858.75</dia_12b>
<dia_14b>4500</dia_14b>
<dia_16b>5145</dia_16b>
</table_row>
</table>
</fastener>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi ="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns="http://my-company.com/namespace">

<xsl:template match="/">
<html>
<body>
<h2>Fastener Table</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Row</th>
<th align="left">Thickness</th>
</tr>
<xsl:for-each select="fastener/table/table_row">
<tr>
<td><xsl:value-of select="row_id"/></td>
<td><xsl:value-of select="thickness"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://my-company.com/namespace" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://my-company.com/namespace">
<xs:element name="fastener">
<xs:complexType>
<xs:sequence>
<xs:element name="table">
<xs:complexType>
<xs:sequence>
<xs:element name="table_row" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="row_id"/>
<xs:element name="thickness"/>
<xs:element name="dia_3b" minOccurs="0"/>
<xs:element name="dia_4b"/>
<xs:element name="dia_5b"/>
<xs:element name="dia_6b"/>
<xs:element name="dia_7b"/>
<xs:element name="dia_8b"/>
<xs:element name="dia_9b"/>
<xs:element name="dia_10b"/>
<xs:element name="dia_12b"/>
<xs:element name="dia_14b"/>
<xs:element name="dia_16b"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="table_number" type="xs:integer" use="required"/>
<xs:attribute name="bolt_material" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=http://www.webdeveloper.com/forum/archive/index.php/"ALLOY-STEEL"/>
<xs:enumeration value="STEEL"/>
<xs:enumeration value="TITANIUM"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="bolt_head" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="COUNTERSUNK"/>
<xs:enumeration value="PROTRUDING_HEAD"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="joint_material" type="xs:string" use="required"/>
<xs:attribute name="bolt_applicability" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
 
Back
Top