08.08.2017 Views

designer

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

160 Chapter 5 Working with Data Views<br />

<br />

<br />

<br />

Adventure Works<br />

<br />

<br />

<br />

<br />

When an XML document contains data that does not follow the XML rules (for<br />

example, if you want to include HTML or code in the XML document), you should<br />

include the data in an XML CDATA section to indicate that it should not be parsed<br />

as XML.<br />

Using XSLT<br />

Data Views use XSLT to describe how to transform the XML data that SharePoint retrieves<br />

from a data source to HTML. SharePoint first converts the XML data into an XML<br />

tree, which represents the hierarchical structure of the XML elements and attributes,<br />

known as nodes. The Date Source Details task pane shows this hierarchical structure in<br />

a way similar to a folder structure on a file system, with the list or library represented as<br />

a Rows XML element, the list item represented as a Row XML child element, and each<br />

field represented as an XML attribute. (In XSLT, XML attributes are prefixed with the @<br />

symbol.) The XSLT is then used to navigate the hierarchical structure, and the XML Path<br />

Language (XPath) is used to select one or more nodes.<br />

The XSLT instructions themselves are also represented as XML data. The xsl:template<br />

element contains a match attribute that defines the XPath expression used to select the<br />

set of nodes to be transformed. After a node is selected, components specify how to<br />

manipulate the XML data. These components can include HTML formatting tags and<br />

other XSLT elements. For example, in the following XSLT, the xsl:template element finds<br />

the Invoice XML element, and the HTML formats the xsl:value-of element. Using the<br />

XML data given as an example in the sidebar “An XML Primer,” this XSLT would render<br />

Adventure Works as a new paragraph in bold font.<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!