Skip to main content
December 1, 2010
Question

Binding XSL to XML using Dreamweaver 8

  • December 1, 2010
  • 2 replies
  • 772 views

Sorry for cross-posting but Paul suggested I might have better results if I posted this here.

Hi,

I posted something a  couple of days ago to the Dreamweaver forum about using the Application panel to bind elements in  a schema to an XML document. I haven't gotten a response so let me add a  little more detail. First of all, I am using Lucinda Dykes Dreamweaver 8  Advanced book to help with setting this up. The bindings appear to be  in place but when I attach the XSLT fragment to the XML document and  preview, it displays the binding instructions(page/SpecialCollections/Collection/LouiseFortuneHall/Location/Title) and not the elements from  the source tree. Here is what the code looks like:

<?xml version="1.0" encoding="iso-8859-1"?><!-- DWXMLSource="HallCollection1.xml" -->
<!DOCTYPE xsl:stylesheet  [
    <!ENTITY nbsp   "&#160;">
    <!ENTITY copy   "&#169;">
    <!ENTITY reg    "&#174;">
    <!ENTITY trade  "&#8482;">
    <!ENTITY mdash  "&#8212;">
    <!ENTITY ldquo  "&#8220;">
    <!ENTITY rdquo  "&#8221;">
    <!ENTITY pound  "&#163;">
    <!ENTITY yen    "&#165;">
    <!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:template match="/"><table width="85%" border="1" cellpadding="2">
  <xsl:for-each select="page/SpecialCollections/Collection/LouiseFortuneHall/Location ">
    <tr>
      <th scope="row">Title</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Title</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Subject</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Subject</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Description</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Description</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Type</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Type</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Source</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Source</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Creator</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Creator</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Rights</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Rights</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Date</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Date</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Format</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Format</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Identifier</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Identifier</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">RightsHolder</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/RightsHolder</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">AccrualMethod</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/AccrualMethod</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">AccrualPeriodicty</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/AccrualPeriodicty</td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">AccrualPolicy</th>
      <td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/AccrualPolicy</td>
      <td> </td>
    </tr>
  </xsl:for-each>
 
</table>

</xsl:template>
</xsl:stylesheet>

This is the beginning of the document I am trying to format, a fragment from a much larger xml file for some archival material we are cataloging:

<?xml version="1.0"?>
<?xml-stylesheet href="HallCollection3.xsl" type="text/xsl"?>
<page>
<SpecialCollections>
  <Collection>
   <LouiseFortuneHall>
    <Location ID='SB-B'>
     <!--Documents related to the History of Damascus, focusing primarily on economic development in the 20th Century and various industrial enterprises in which George A. Hall (and presumably Louise Fortune Hall) were investors, officers and or stockholders-->
     
     <Title File='SB-B1'>Letter From Bud Wright, Questions about Kettlefoot, Elliot Roosevelt</Title>
     <Subject>"Kettlefoot Flannagan"</Subject>
     <Subject>"Elliot Roosevelt"</Subject>
     <Description>"Personal communication from L.F. Hall addressed to Bud and Martha Wright in response to letter from correspondents regarding visits by Eleanor Roosevelt to Southwest Virginia and other historical details related to Damascus and White Top.</Description>
     <Type>Text</Type>
     <Source>Hall Collection</Source>
     <Coverage></Coverage>
     <Creator></Creator>
     <Publisher></Publisher>
     <Rights></Rights>
     <Date>1985-04-23</Date>
     <Format>Draft</Format>
     <Identifier></Identifier>
     <RightsHolder>Washington County Public Library</RightsHolder>
     <AccrualMethod>Donation</AccrualMethod>
     <AccrualPeriodicty>Irregular</AccrualPeriodicty>
     <AccrualPolicy>Active</AccrualPolicy>

If anyone can help I'd be truly obliged.

Will

This topic has been closed for replies.

2 replies

December 2, 2010

This worked nicely. Thanks, David

David_Powers
Inspiring
December 2, 2010

pbody2008 wrote:

when I attach the XSLT fragment to the XML document and  preview, it displays the binding instructions(page/SpecialCollections/Collection/LouiseFortuneHall/Loc ation/Title) and not the elements from  the source tree.

That's because the binding instructions should be XSL elements. I don't know how you have created the XSL fragment, but based on the XML document you have supplied, the XSL file should look like this:

<?xml version="1.0" encoding="iso-8859-1"?><!-- DWXMLSource="HallCollection1.xml" -->
<!DOCTYPE xsl:stylesheet  [
    <!ENTITY nbsp   "&#160;">
    <!ENTITY copy   "&#169;">
    <!ENTITY reg    "&#174;">
    <!ENTITY trade  "&#8482;">
    <!ENTITY mdash  "&#8212;">
    <!ENTITY ldquo  "&#8220;">
    <!ENTITY rdquo  "&#8221;">
    <!ENTITY pound  "&#163;">
    <!ENTITY yen    "&#165;">
    <!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:template match="/"><table width="85%" border="1" cellpadding="2">
  <xsl:for-each select="page/SpecialCollections/Collection/LouiseFortuneHall/Location ">
    <tr>
      <th scope="row">Title</th>
      <td><xsl:value-of select="Title"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Subject</th>
      <td><xsl:for-each select="Subject">
        <xsl:value-of select="."/>
        <xsl:text>, </xsl:text>
      </xsl:for-each></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Description</th>
      <td><xsl:value-of select="Description"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Type</th>
      <td><xsl:value-of select="Type"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Source</th>
      <td><xsl:value-of select="Source"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Creator</th>
      <td><xsl:value-of select="Creator"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Rights</th>
      <td><xsl:value-of select="Rights"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Date</th>
      <td><xsl:value-of select="Date"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Format</th>
      <td><xsl:value-of select="Format"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">Identifier</th>
      <td><xsl:value-of select="Identifier"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">RightsHolder</th>
      <td><xsl:value-of select="RightsHolder"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">AccrualMethod</th>
      <td><xsl:value-of select="AccrualMethod"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">AccrualPeriodicty</th>
      <td><xsl:value-of select="AccrualPeriodicty"/></td>
      <td> </td>
    </tr>
    <tr>
      <th scope="row">AccrualPolicy</th>
      <td><xsl:value-of select="AccrualPolicy"/></td>
      <td> </td>
    </tr>
  </xsl:for-each>

</table>
</xsl:template>
</xsl:stylesheet>

Just to take the first table cell, you have this:

<td>page/SpecialCollections/Collection/LouiseFortuneHall/Location/Title</td>

It should be this:

<td><xsl:value-of select="Title"/></td>

I haven't read Lucinda Dykes' book, but I've just had a quick look at her description of server-side XSLT through my subscription to the Safari Online Library. It looks OK to me, so you've obviously gone wrong somewhere. Take a look at Figure 14-34 at the bottom of page 349. Notice that the bindings are shown in Design view in curly braces. That's Dreamweaver's way of displaying the <xsl:value-of> tags.

I covered the use of XSLT fragments in much greater detail in my books, "Foundation PHP for Dreamweaver 8" and "The Essential Guide to Dreamweaver CS3 with CSS, Ajax, and PHP". Both books are still in print. In fact, if you have access to the Safari Online Library, you'll find the CS3 book there (http://my.safaribooksonline.com/book/web-design-and-development/9781590598597). The XSLT material is in Chapter 18. Even if you're using Dreamweaver 8, the code is the same.