[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Does WTSIWYG make simplicity moot?


wtsiwyg
On 13 Nov 2002 at 11:49, Jeff Lowery wrote:

> Example:
>  
> <rect x="10" y="10" width="50" height="30" style="stroke: black; fill:
> none;"/>
>  
> The style attribute contains structured content. This means in addition to
> an XML parser, there has to be a stylesheet parser.

It also makes XSLT processing vastly more complicated. Say you want
to change the fill color on all filled objects to 'blue', but leave
the unfilled ones alone. With discrete style attributes, you can do
this:

  <xsl:apply-templates select="@fill"/>

  <xsl:template match="@fill[normalize-space() = 'none']">
    <xsl:copy-of select="."/>
  </xsl:template>

  <xsl:template match="@fill">
    <xsl:attribute name="fill">blue</xsl:attribute>
  </xsl:template>

Whereas if you use the single 'style' attribute, you have to resort
to something ugly and inefficient like:

  <xsl:call-template name="process-style">
    <xsl:with-param name="style" select="@style"/>
  </xsl:call-template>

  <xsl:template name="process-style">
    <xsl:param name="style"/>
    <xsl:variable name="property"
      select="substring-before($style,';')"/>
    <xsl:variable name="property-name"
      select="normalize-space(substring-before($property, ':'))"/>
    <xsl:variable name="property-value"
      select="normalize-space(substring-after($property, ':'))"/>
    <xsl:attribute name="$property-name">
      <xsl:choose>
        <xsl:when test="$property-name='fill' and
                        $property-value='none'">
          none
        </xsl:when>
        <xsl:when test="$property-name='fill'">
          blue
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$property-value/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
    <xsl:variable name="remainder"
      select="substring-after($style,';')"/>
    <xsl:if test="$remainder">
      <xsl:call-template name="process-style">
        <xsl:with-param name="style" select="$remainder"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

Ow! That's even worse than I thought. I've never actually done that
before, just thought about it.

--
Matt Gushee

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.