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

WordML Question and normalize-space() question

Subject: WordML Question and normalize-space() question
From: Jordan Soet <jds@xxxxxxxxxxxxxxxxxx>
Date: Fri, 19 May 2006 16:08:01 +0800
wordml problems
First my normalize-space() question... I'm wondering if it's possible to
normalize all the space without removing the leading and trailing
whitespace?

Next, I'm trying to perform conversion from an xml format which contains
XHTML to WordML and I'm having trouble figuring out how to deal with
formatting such as bold, italics, etc. First though, I'm also just having
specific WordML problems, and I was wondering if anyone knew of a list where
I could ask WordML questions on.

Anyways, obviously in XHTML these kind of things can be added to be nested
in each other, such as:

<b> bold text <i> bold and italic </i> just bold again </b>

however, in WordML, it's all a flat structure, so you need to do something
like:

<w:r><w:rPr><w:b/></w:rPr><w:r><w:t>bold text</w:t></w:r>
<w:r><w:rPr><w:b/><w:i/></w:rPr><w:r><w:t>bold and italic</w:t></w:r>
<w:r><w:rPr><w:b/><w:i/></w:rPr><w:r><w:t>bold again</w:t></w:r>


I currently deal with it by calling a template from each formatting element
(b, i, etc.) which checks all its ancestors to see if there's any of the
formatting elements above it, and then applies it to the text() node, and
then calls apply-templates to everything below it, like follows:

	<w:r>
		<w:rPr>
			<xsl:if
test="ancestor-or-self::xhtml:strong|ancestor-or-self::xhtml:b|ancestor-or-s
elf::b">
				<w:b/>
			</xsl:if>
			<xsl:if
test="ancestor-or-self::xhtml:em|ancestor-or-self::i">
				<w:i/>
			</xsl:if>
			<xsl:if test="ancestor-or-self::xhtml:u">
				<w:u w:val="single"/>
			</xsl:if>
			<xsl:if
test="ancestor-or-self::xhtml:a|ancestor-or-self::link|ancestor-or-self::Lin
k_Text">
				<w:color w:val="0000FF"/>
				<w:u w:val="single"/>
			</xsl:if>
		</w:rPr>
		<w:t><xsl:value-of select="text()"/></w:t>
	</w:r>

	<xsl:apply-templates/>

However, this only works if the text is immediately nested inside the
elements, like this:

<b><i>bold and italic text</b></i>

and not in cases like the earlier example, where I then end up with
something like the following:

<b> bold text just bold again</b><b><i>bold and italic</b></i>

And I'm not really sure how to fix it.

So, hopefully that made sense, and any help is appreciated,

Thanks,
Jordan

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.