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

dynamically generating css

Subject: dynamically generating css
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Mon, 30 Aug 2004 17:21:48 -0400
generating css
A couple of weeks back, Jeni helped me with a suggestion on how to read an external (non-xsl) xml file to configure output formatting. So one big part of this is it should iterate over the elements and create CSS definitions where there are appropriate attributes.

I'm making progress on this, but I'm stuck in only get one element output.

So, I have this input:

	<reftype name="book">
	  <creator after=" ">
	    <name/>
	    <role before=" "/>
	  </creator>
	  <date after=". ">
	    <year/>
	  </date>
	  <title font-style="italic" after=". "/>
	  <genre after=" "/>
	  <medium before="[" after="], "/>
	  <origin>
	    <place/>
	    <publisher before=":"/>
	  </origin>
	  <physical-location before=", available at "/>
	  <url/>
	</reftype>
	<reftype name="chapter">
	  <creator/>
	  <date before=" " after=". ">
	    <year/>
	  </date>
	  <title after=". "/>
	  <container before="In ">
	    <title font-style="italic" after=", "/>
	    <creator>
	      <role after=" "/>
	      <name/>
	    </creator>
	    <part-details before=", ">
	      <pages/>
	    </part-details>
	    <origin before=".">
	      <place/>
	      <publisher before=":"/>
	    </origin>
	  </container>
	  <genre before=", "/>
	  <medium before="(" after="), "/>
	  <physical-location/>
	  <url/>
	</reftype>

I get this output:

..book-title{
font-style: italic;
  }

This is correct as far it goes, but I need the other definitions too. In this case, I should also get:

..chapter-container-title{
font-style: italic;
  }

Stylesheet, where I obviously am doing something wrong with the cs:reftype template):

  <xsl:template name="css" match="cs:citationstyle">
    <xsl:apply-templates select="//cs:reftype"/>
  </xsl:template>

<xsl:template match="cs:reftype">
<xsl:param name="style" as="element()" select="."/>
<xsl:variable name="reftype-name" select="@name"/>
<xsl:variable name="source" as="element()" select="." />
<xsl:for-each select="$style/*[@font-style | @font-weight]">
..<xsl:value-of select="$reftype-name"/>-<xsl:value-of select="name(.)"/>{<xsl:apply-templates
select="$source/*[node-name(.) = node-name(current())]">
<xsl:with-param name="style" select="." />
</xsl:apply-templates>}
</xsl:for-each>
</xsl:template>


<xsl:template match="cs:*">
<xsl:apply-templates select="@font-family | @font-style | @font-weight"/>
</xsl:template>


  <xsl:template match="@font-family">
font-family: <xsl:value-of select="."/>;
  </xsl:template>

  <xsl:template match="@font-style">
font-style: <xsl:value-of select="."/>;
  </xsl:template>

  <xsl:template match="@font-weight">
font-weight: <xsl:value-of select="."/>;
  </xsl:template>

Bruce

Current Thread

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
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.