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

Screening values from two attribute-sets

Subject: Screening values from two attribute-sets
From: "Kyle Partridge" <kpartridge@xxxxxxxxxxxx>
Date: Wed, 11 Feb 2004 16:33:15 -0500
style text align
Hi List,

This might seem like a dumb question, but if someone could point me in
the right direction to solve this problem, I'd be very grateful.

Basically, I've got an xml document that has both styles, and individual
style overrides possible on each p tag.  Note that all the
lengths/amounts are assumed to be in pts.  Here's a short sample:

<worksheet>
	<settings>
		<presentation>
			<textRendering>
				<textStyles>
					<textStyle name="Normal">
						<blockAttr
margin-left="0" margin-right="0" text-indent="0" text-align="left"/>
					</textStyle>
					<textStyle name="Derived"
base-style="Normal">
						<blockAttr
margin-left="inherit" margin-right="inherit" text-indent="36"
text-align="inherit"/>
					</textStyle>
				</textStyles>
			</textRendering>
		</presentation>
	</settings>
	<regions>
		<region region-id="1" align-x="0" align-y="0" top="36"
left="36" height="200" width="288" is-protected="false"
show-border="false" show-highlight="false" background-color="inherit">
			<text>
				<p style="Normal" text-align="right">
					Normal style. Text-align
overriden to right.
				</p>
				<p style="Derived">
					Derived style. Inherits from the
normal style.
				</p>
			</text>
		</region>
	</regions>
</worksheet>

What I want to be able to do is this:

<fo:block-container absolute-position="fixed" top="36pt" left="36pt"
height="200pt" width="288pt" background-color="#000">
	<fo:block>
	<fo:block-container margin-left="0pt" margin-right="0pt"
text-indent="0pt" text-align="right">
		<fo:block
font-selection-strategy="character-by-character"
line-stacking-strategy="max-height">
			<fo:inline>
			Normal style. Text-align overridden to right.
			</fo:inline>
		</fo:block>
	</fo:block-container>
	<fo:block-container margin-left="0pt" margin-right="0pt"
text-indent="36pt" text-align="left">
		<fo:block
font-selection-strategy="character-by-character"
line-stacking-strategy="max-height">
			<fo:inline>
				Derived style. Inherits most things from
the Normal style.
			</fo:inline>
		</fo:block>
	</fo:block-container>
	</fo:block>
</fo:block-container>

The good news is, most of what I'm doing works.  I'm getting ALMOST what
I'm showing above.  The problem is, when I process each p, I want to use
the attribute values that the p is using first, but then, I want to get
all the assigned style attribute values for the attributes that weren't
specified in the p.  If the p says p text-align="right", for instance, I
want the final block-container to have text-align="right" but everything
else the same as the specified style.  I tried to do this like this:

<xsl:template match="ws:p">
	<xsl:variable name="style-name" select="@style"/>
	<xsl:element name="fo:block-container">
		<xsl:choose>
			<xsl:when test="@*">
				<xsl:variable
name="att-name"><xsl:value-of select="name(.)"/></xsl:variable>
				<xsl:variable
name="path-name"><xsl:text>@</xsl:text><xsl:value-of
select="name(.)"/></xsl:variable>
				<xsl:for-each
select="//ws:textStyle[@name=$style-name]/ws:blockAttr/@*">
				<xsl:choose>
					<!-- **** THIS DOESN'T WORK ****
-->
					<xsl:when
test="$att-name=name(.)">
						<xsl:apply-templates
select="$path-name" mode="blockAttrs"/>
					</xsl:when>
					<!-- **** END PART THAT DOESN'T
WORK **** -->
					<xsl:otherwise>
						<xsl:apply-templates
select="." mode="blockAttrs"/>
					</xsl:otherwise>
				</xsl:choose>				
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates
select="//ws:textStyle[@name=$style-name]/ws:blockAttr/@*"
mode="blockAttrs"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:element>
</xsl:template>

But, of course, as you can probably already see, I figure I must be
approaching the problem all wrong, because it just doesn't work.  Any
suggestions you have for how I could better approach this problem would
be must welcome.

Sincerely,

Kyle Partridge



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.