<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'

xmlns='http://www.w3.org/Graphics/SVG/SVG-19990812.dtd'>

<xsl:output method='xml' indent='yes' media-type='image/svg'/>

<xsl:template match='/'>

<svg width = «3in» height='3in'>

<g style = «stroke: #000000»>

<!– draw the axes ->

<line x1='0' x2='150' y1='150' y2='150'/>

<line x1='0' x2='0' y1='0' y2='150'/>

<text x='0' y='10'>Revenue</text>

<text x='150' y='165'>Division</text>

<xsl:for-each select='sales/division'>

<!– define some useful variables ->

<!– the bar's x position ->

<xsl:variable name='pos' select='(position()*40)-30'/>

<!– the bar's height ->

<xsl:variable name='height' select='revenue*10'/>

<!– the rectangle ->

<rect x='{$pos}' y='{150-$height}' width='20' height='{$height}'/>

<!– the text label ->

<text x='{$pos}' y='165'>

<xsl:value-of select='@id'/>

</text>

<!– the bar value ->

<text x='{$pos}' y='{145-$height}'>

<xsl:value-of select='revenue'/>

</text>

</xsl:for-each>

</g>

</svg>

</xsl:template>

</xsl:stylesheet>

Полученный SVG документ:

<svg width='3in' height='3in' xmlns='http://www.w3.org/Graphics/SVG/svg-19990412.dtd'> <g style='stroke: #000000'>

<line x1='0' x2='150' y1='150' y2='150'/>

<line x1='0' x2='0' y1='0' y2='150'/>

<text x='0' y='10'>Revenue</text>

<text x='150' y='165'>Division</text>

<rect x='10' y='50' width='20' height='100'/>

<text x='10' y='165'>North</text>

<text x='10' y='45'>10</text>

<rect x='50' y='110' width='20' height='40'/>

<text x='50' y='165'>South</text>

<text x='50' y='105'>4</text>

<rect x='90' y='90' width='20' height='60'/>

<text x='90' y='165'>West</text>

<text x='90' y='85'>6</text>

</g>

</svg>

Следующий стиль преобразует данные в VRML:

<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<!– generate text output as mime type model/vrml, using default charset ->

<xsl:output method='text' encoding='UTF-8' media-type='model/vrml'/>

<xsl:template match='/'>#VRML V2.0 utf8

# externproto definition of a single bar element EXTERNPROTO bar [ field SFInt32 x field SFInt32 y field SFInt32 z field SFString name ] «http://www.vrml.org/WorkingGroups/dbwork/barProto.wrl»

# inline containing the graph axes Inline { url «http://www.vrml.org/WorkingGroups/dbwork/barAxes.wrl» }

<xsl:for-each select='sales/division'> bar { x <xsl:value-of select='revenue'/> y <xsl:value-of select='growth'/> z <xsl:value-of select='bonus'/> name «<xsl:value-of select=»@id'/>' } </xsl:for-each>

</xsl:template>

</xsl:stylesheet>

Полученный VRML документ:

#VRML V2.0 utf8

# externproto definition of a single bar element EXTERNPROTO bar [ field SFInt32 x field SFInt32 y field SFInt32 z field SFString name ] «http://www.vrml.org/WorkingGroups/dbwork/barProto.wrl»

# inline containing the graph axes Inline { url «http://www.vrml.org/WorkingGroups/dbwork/barAxes.wrl» }

bar { x 10 y 9 z 7 name «North» } bar { x 4

y 3 z 4 name «South» }

bar { x 6

y -1.5 z 2 name «West» }

e Благодарности (пояснения к спецификации)

В разработку предварительного варианта документа вклад внести следующие лица:

Daniel Lipkin, Saba

Jonathan Marsh, Microsoft

Henry Thompson, Университет Эдинбурга

Norman Walsh, Arbortext

Steve Zilles, Adobe

Данная спецификация была разработана и одобрена для публикации рабочей группой по XSL из

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату
×