Jump to content

tombliboo

Members
  • Posts

    7
  • Joined

  • Last visited

tombliboo's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Here is my schema, what I'm unable to do is set unique restrictions on the title element. <?xml version="1.0" encoding="ISO-8859-1"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="departments"> <xs:complexType> <xs:sequence> <xs:element ref="department" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="department"> <xs:complexType> <xs:sequence> <xs:element ref="title" minOccurs="1" maxOccurs="1"/> <xs:element ref="subdepartment" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="title"> <xs:simpleType> <xs:restriction base="xs:string"/> </xs:simpleType> </xs:element> <xs:element name="subdepartment"> <xs:simpleType> <xs:restriction base="xs:string"/> </xs:simpleType> </xs:element></xs:schema> What I'm trying is this within the title element tag, XMLSpy accepts it as valid but the restriction does not work if I test duplicate titles in my XML. <xs:unique name="testUnique"> <xs:selector xpath="department"/> <xs:field xpath="title"/></xs:unique> Please help!
  2. HiI've read a number of threads and tried the reccomendations, switching between UTF-8 and IS0-8859-1, using £ or £ or £ and I've upgraded to Internet Explorer 8 as I was still running IE6 on my test system.Despite these efforts stil where £ should be output it appears as:£Can anyone help?Thanks
  3. Further info, example of input xml: <?xml version = "1.0" encoding = "UTF-8"?><departments> <department> <title>Department 1</title> <subdepartment>Dept 1 Sub Dept 1</subdepartment> <subdepartment>Dept 1 Sub Dept 2</subdepartment> </department> <department> <title>Department 2</title> <subdepartment>Dept 2 Sub Dept 1</subdepartment> <subdepartment>Dept 2 Sub Dept 2</subdepartment> </department> <department> <title>Department 3</title> <subdepartment>Dept 3 Sub Dept 1</subdepartment> <subdepartment>Dept 3 Sub Dept 2</subdepartment> </department></departments> The code I'm currently working on I have positioned immediately after the last result-document tag in my above stylessheet: <!-- Creating the index file--><xsl:result-document href="output/index.html" format="html"><html><head><title>Index Page</title></head> <body> <xsl:for-each select="departments/department/subdepartment"> <xsl:variable name="varDept" select="../title"/> <a href="'{$varDept}, - ',{.}'.html"><xsl:value-of select="concat($varDept,' - ',.,'.html')"/> </a><br/> </xsl:for-each> </body></html> </xsl:result-document> This generates a blank index.html, only two of the sub department pages where there should be 16 (and works if I remove my Index creating code) and returns the error:Error at xsl:result-document on line 44 of copystylesheet.xslt:XTDE1490: Cannot write more than one result document to the same URI:file:/C:/websites/diecastcars/webpages/index.html at xsl:apply-templates (file:/C:/websites/diecastcars/copystylesheet.xslt#23) processing /categories/category[1]/subcategory[2] at xsl:apply-templates (file:/C:/websites/diecastcars/copystylesheet.xslt#19) processing /categories/category[1] at xsl:apply-templates (file:/C:/websites/diecastcars/copystylesheet.xslt#12) processing /categoriesTransformation failed: Run-time errors were reportedNB: line 44 is:<xsl:result-document href="output/index.html" format="html">
  4. HiI'm generating the webpages for my website as per my code below, I'm having difficulty generating an Index.html page to go alongside these files, can anyone help? <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"><xsl:output method="html" indent="yes" name="html"/><xsl:template match="/"><html> <style type="text/css"> table { border: solid 3px #000000;} th,td { border: solid 3px #000000;} </style> <body> <table><th>Title</th><th>Sub Department</th><th></th> <xsl:apply-templates select="departments"/> </table> </body></html> </xsl:template> <xsl:template match="department"> <xsl:apply-templates select="department"/> </xsl:template> <xsl:template match="department"> <xsl:apply-templates select="subdepartment"> <xsl:with-param name="title" select="title"/> </xsl:apply-templates> </xsl:template> <xsl:template match="subdepartment"> <xsl:param name="title"/> <xsl:variable name="subdept" select="(.)"/> <xsl:variable name="filename" select="concat('output/',$title,' - ',.,'.html')"/> <tr><td><xsl:value-of select="$title"/></td> <td><xsl:value-of select="concat(.,'.html')"/></td> <td><a href="{$filename}">select</a></td></tr> <!-- webpages in html file --> <xsl:result-document href="{$filename}" format="html"> <html> <body> <!-- my page code sits here--> </body> </html> </xsl:result-document> </xsl:template></xsl:stylesheet> This generates my pages in the form of:Department 1 - Sub Department 1.htmlDepartment 1 - Sub Department 2.htmlDepartment 2 - Sub Department 1.htmlDepartment 2 - Sub Department 2.html...and so on. I would like an Index which for the time being just includes hyperlinks to each page, and preferably a higher level link for each department which takes you to the first sub department within it.I'm still trying to achieve this but in the meantime any assistance is much appreciated, my current attempts fail with errors such as:Cannot write one than one result document to the same URI;Or my variables store both sub departments in the same stringBy the way I'm parsing this stylesheet through Saxon.Many thanks
  5. All products are listed within the same xml file, so I've been working with the document() function and produced the following code, I'm trying to look into the xml file to search through all products and pull out information for those products which match the current subcategory webpage being generated. <xsl:template match="/"><html><body><xsl:for-each select="document('products.xml')/catalog/product/include"> <xsl:if test="subcategory='Diecast Cars'"> <table> <tr> <td><xsl:value-of select="/catalog/product/title"/></td> </tr> </table> </xsl:if></xsl:for-each> </body></html></xsl:template> This is returning: <html> <body> <table> <tr> <td>Title1 Title2 Title3</td> </tr> </table> <table> <tr> <td>Title1 Title2 Title3</td> </tr> </table> <table> <tr> <td>Title1 Title2 Title3</td> </tr> </table> </body></html> I'm testing with just 3 products, each of them are to be included in the specified subcategory but as you can see all 3 product titles are being returned in each run.I'm reading about xsl:key, to return unique keys but struggling to apply it, is this the best option and if so how is it set, please help?
  6. HiI'm parsing a xml file through Saxon which generates the structure of my website in that it produces the relevant pages, however currently all my xsl:result-document code achieves is to output the title of the page and provide a link back to my index.What I now need to achieve is to extract the details of my products from a seperate xml file as relevant, a simplified copy of that file is below the real thing contains hundreds of records (please tell me its set out OK!).A few comments in terms of the schema, each product:Must have:<productid><title><price><image><desc><stock><incl ude>May not have:<imagelarge> (If missing don't show a link)<features>May have numerous:<features> (Display all in a list><include> (Display in multiple categories)The nodes to display on the page are:TitleImage (with link if <imagelarge> is available)TitlePriceStock (if in stock, a link/button 'buy')DescriptionFeatures (if available)Please help me my shop could be making me money! Anyone like toy cars by the way? I know I know I'm doomed! ANY advice greatly appreciated. <?xml version = "1.0" encoding = "UTF-8"?><catalog> <product> <productid>0001</productid> <title>Product 1</title> <price>2.99</price> <image>prod1.jpg</image> <imagelarge>prod1x.jpg</imagelarge> <desc>A description of product 1.</desc> <features>Prod1 feature</features> <features>Prod1 another feature</features> <stock>In Stock</stock> <include> <category>This Category</category> <subcategory>This Subcategory 1</subcategory> </include> <include> <category>This Category</category> <subcategory>This Subcategory 4</subcategory> </include> </product> <product> <productid>0002</productid> <title>Product 2</title> <price>1.99</price> <image>prod2.jpg</image> <imagelarge>prod2x.jpg</imagelarge> <desc>A description of product 2.</desc> <features>Prod2 only one feature</features> <stock>Out of Stock</stock> <include> <category>That Category</category> <subcategory>That Subcategory 3</subcategory> </include> </product></catalog>
×
×
  • Create New...