xsl-list
[Top] [All Lists]

Re: [xsl] wordml to xml with pStyle as tags

2006-03-24 12:18:46
At 2006-03-24 13:51 -0500, Terry Ofner wrote:
I would like to take the pStyle attribute; convert it into an element tag and surround the w:t text with the tags.

Here is an example of a wordml snippet:
...(copied below)...
I would like to get output something like this:

<A-Head>Nouns</A-Head>
<Textwindent>A dictionary lists thousands of words. All these words can be divided into eight groups called the parts of speech. A word's part of speech is determined by the job it does in a sentence.</Textwindent>

I'm not sure what questions you have ... you've only given before and after and not where you are having the problem understanding your XSLT.

A very short stylesheet is all that is needed.

I hope this helps.

. . . . . .  Ken

T:\ftemp>type ofner.xml
<w:body xmlns:w="urn:x-this" xmlns:wx="urn:x-that">
  <wx:sect>
    <w:p>
      <w:pPr>
        <w:pStyle w:val="A-Head"/>
      </w:pPr>
      <w:r>
        <w:t>Nouns</w:t>
      </w:r>
    </w:p>
    <w:p>
      <w:pPr>
        <w:pStyle w:val="Textwindent"/>
      </w:pPr>
      <w:r>
        <w:t>A dictionary lists thousands of words. All
these words can be divided into eight groups called the
parts of speech. A word's part of speech is determined
by the job it does in a sentence.</w:t>
      </w:r>
    </w:p>
  </wx:sect>
</w:body>
T:\ftemp>xslt ofner.xml ofner.xsl con
<?xml version="1.0" encoding="utf-8"?>

    <A-Head>Nouns</A-Head>
    <Textwindent>A dictionary lists thousands of words. All
these words can be divided into eight groups called the
parts of speech. A word's part of speech is determined
by the job it does in a sentence.</Textwindent>


T:\ftemp>type ofner.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:w="urn:x-this" xmlns:wx="urn:x-that"
                version="1.0">

<xsl:template match="w:p">
  <xsl:element name="{w:pPr/w:pStyle/@w:val}">
    <xsl:apply-templates select="w:r/w:t/node()"/>
  </xsl:element>
</xsl:template>

</xsl:stylesheet>
T:\ftemp>

--
Upcoming XSLT/XSL-FO hands-on courses: Washington,DC 2006-06-12/16
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>