Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Conversions / November 2004

Tip: Looking for answers? Try searching our database.

generating table of contents using word ml

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chaitu - 16 Nov 2004 19:38 GMT
Hello,

Is there someway of automatically generating table of contents using wordml
(instead of using vba or vb ).

I'm using xslt to transform my xml doc. into wordml. the xml doc has section
headers, which are to be included in the table of contents and also the table
of contents must have the page no.s where the section headers appeared on the
document.

Could someone indicate a way of doing it please. I've been trying to find
something in realtion to this, but was not able to find any info.

Thank You,
Chaitu
Margaret Aldis - 16 Nov 2004 22:08 GMT
Hi Chaitu

I can't tell you how to do this but I can probably give you somewhere to
start.

In the target Word document, what you need is a TOC field to pick up the
headings (either by level or by style).

I suggest you first create the field you want in a trial document, using
Insert > References > Index and Tables. Save out to WordXML, and look at the
code generated for the TOC field. You should then be able to write the XSLT
to recreate the code for the field at the appropriate point in the document.

Signature

Margaret Aldis - Microsoft Word MVP
Syntagma partnership site: http://www.syntagma.co.uk
Word MVP FAQ site: http://www.word.mvps.org

> Hello,
>
[quoted text clipped - 11 lines]
> Thank You,
> Chaitu
Chaitu - 17 Nov 2004 00:04 GMT
Hi Margaret,

Thanks for the reply.

But I already tried this (actually this is how I'm generating all my xslt
for the xml). But for TOC it is generating a bunch of stuff which I dont know
how to generate using xslt., Can you please suggest where detailed info about
the wordml can be found.

I went through many sites, but almost every website has the same info, and
the table of contents is not discussed anywhere. Even the wordml document
from microsoft just mentions it, but doesnt tell how to use it.

Could you please suggest someway of doing it.

Thanks for the info,
Chaitu

> Hi Chaitu
>
[quoted text clipped - 28 lines]
> > Thank You,
> > Chaitu
Margaret Aldis - 17 Nov 2004 12:01 GMT
Hi Chaitu

OK, having looked at the XML I guess what is probably confusing is that Word
stores the *result* of the field in with the field code. In the case of a
full-blown TOC that would list sections from the document, which obviously
you couldn't easily generate. However, there is no need to include the
correct result in the XML, only the correct field code.

Try the following:

Insert a TOC field in an otherwise empty document, and save as XML. In the
output, you will see the field appear towards the end of the file between

   <w:fldChar w:fldCharType="begin"/>

and

    <w:fldChar w:fldCharType="end"/>

The field code appears as

    <w:instrText> TOC \o "1-3" </w:instrText> - this is what you might need
to adjust to match the actual field code you need to pick up your section
headings. You can get that information from the field code Help, or by
examining the code (toggle field codes to see it) in a working Word
document.

In the trial blank document, the field value appears as:

    <w:t>Error! No table of contents entries found.</w:t>

That is the text that is displayed in the file. But you can edit this text
to anything you like, resave the file, and reopen in Word and the TOC field
will still work (i.e. generate the correct TOC when you add Headings to the
document.) So it's clear that if your XSLT simply puts any placeholder text
here, you will be generating a valid Word document with a 'live' TOC - you
just need to update the field to see it.

Hope this helps.

Signature

Margaret Aldis - Microsoft Word MVP
Syntagma partnership site: http://www.syntagma.co.uk
Word MVP FAQ site: http://www.word.mvps.org

> Hi Margaret,
>
[quoted text clipped - 46 lines]
> > > Thank You,
> > > Chaitu
Chaitu - 29 Nov 2004 14:41 GMT
Hi Margaret,

Sorry for not replying so long. I kind of gave up on this as its taking a
long time and it was kind of urgent. So I'm using visual basic to generate
the TOC instead. Its working fine for now.

Thanks a lot for your time,
Chaitu

> Hi Chaitu
>
[quoted text clipped - 94 lines]
> > > > Thank You,
> > > > Chaitu
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.