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

Re: XSL for WordML -> specific HTML

Subject: Re: XSL for WordML -> specific HTML
From: JBryant@xxxxxxxxx
Date: Thu, 5 May 2005 10:33:06 -0500
wordml div
Hi, Stephen,

I've done a little WordML to XHTML and WordML to FO, so maybe I can help a 
bit.

Your heading templates look fine to me. They'll get you the values of the 
headings without anything you don't want. I suppose you think they're 
messy because you don't want to apply multiple templates to the same 
element. However, your current solution works just as well as matching 
w:pPr and applying logic within the template to figure out which heading 
level it is. Personally, I find having one template per type of result 
node to be just as readable as one template per type of source node.

To get the content of the paragraphs, add this to your heading templates:

<xsl:template match="w:p/w:r/w:t">
  <p><xsl:apply-templates/></p>
</xsl:template>

I used apply-templates there because you may have format elements (bold, 
etc.) within the paragraph. I used the three level match to make sure you 
get just body content and not the heading content, too (as matching just 
w:t or w:r/w:t would do).

HTH

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)




Stephen <azrael@xxxxxxxxxxxxxxxxx> 
05/05/2005 09:34 AM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
cc

Subject
 XSL for WordML -> specific HTML






I have a WordML based xml document which contains content along the 
lines of:

<wx:sub-section>
                 <w:p>
                                 <w:pPr>
                                                 <w:pStyle 
w:val="Heading1"/>
                                 </w:pPr>
                                 <w:r>
                                                 <w:t>Hello 1</w:t>
                                 </w:r>
                 </w:p>
                 <w:p>
                                 <w:r>
                                                 <w:t>Some random normal 
text 1</w:t>
                                 </w:r>
                 </w:p>
                 <wx:sub-section>
                                 <w:p>
                                                 <w:pPr>
                                                                 <w:pStyle 
w:val="Heading2"/>
                                                 </w:pPr>
                                                 <w:r>
 <w:t>Hello 2</w:t>
                                                 </w:r>
                                 </w:p>
                                 <w:p>
                                                 <w:r>
                                                                 <w:t>Some 
random normal text 2</w:t>
                                                 </w:r>
                                 </w:p>

and I want to output that as:

<div style="level1">Hello 1</div>
<p>Some random normal text 1</p>

<div style="level2">Hello 2</div>
<p>Some random normal text 2</p>

Obviously I may have headings all over the document, so I want something 
generic that will pick them all out nicely.

Currently I have a rather messy:

<xsl:template match="w:pStyle[@w:val='Heading1']">
                 <div class="section_L1">
                                 <xsl:value-of 
select="../../w:r/w:t/text()"/>
                 </div>
</xsl:template>

<xsl:template match="w:pStyle[@w:val='Heading2']">
                 <div class="section_L2">
                                 <xsl:value-of 
select="../../w:r/w:t/text()"/>
                 </div>
</xsl:template>

that outputs:

<div class="section_L1"></div><div class="section_L2"></div><div 
class="section_L1">Hello 1</div>Some random normal text 1<div 
class="section_L2">Hello 2</div>Some random normal text 2

Anyone have any useful ideas?


-- 
    Azrael

            ("\''/").___..--'''"-._
            `0_ O  )   `-.  (     ).`-.__.`)
            (_Y_.)'  ._   )  `._ `. ``-..-'
          _..`--'_..-_/  /--'_.' .'
         ((i).-''  ((i).'  (((.-'

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.