Re: Bibliographies in Word 2007

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



See my comments inline.

Yves
--
http://www.codeplex.com/bibliography

On 3 nov, 23:54, Roberto <Robe...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Dear Yves,

I have been using your BibWord and succeded to prepare a custom style(!): I
would have only a couple of questions:

-I am using this code forbibliographybut I can get neither italics nor
bold, and I cannot find the error.


This is because of the way tags are processed. You can not type < or >
directly, you have to use &lt; and &gt;

<format>{%Author:2%}{ (%Year%),}{&lt;i&gt>%Title|ShortTitle%&lt;/
i&gt}, in{ &lt;b&gt%JournalName%&lt;/b&gt}{, %Pages:p. :pp. %}.</
format>

I know it's a bit clumsy but it prevents the possibility of unbalanced
elements showing up in the XSLT.

     <bibliography>
          <columns>1</columns>
          <source type="JournalArticle">
            <column id="1">
                <halign>left</halign>
                <valign>top</valign>
                <format>{%Author:2%}{ (%Year%),}{
<i>%Title|ShortTitle%</i>}, in{ <b>%JournalName%</b>}{, %Pages:p. :pp.
%}.</format>
            </column>
          </source>
          <source type="Book">
            <column id="1">
                <halign>left</halign>
                <valign>top</valign>
                <format>{%Author:2|Editor:3|"[Anonymous]"%}{ (%Year%),}{
<i>%Title|ShortTitle%</i>,}{ %City%}{: %Publisher%}.</format>
            </column>
          </source>
      </bibliography>

- what do the number options mean after the variables? Like in {%Author:2%}:
could I put :1 instead?

Under the bibliography element, there is a namelists element. The
numbers indicate which namelist to use. As long as you define a
namelist with id 'X', you can use that value 'X' when formatting an
author. The idea is to allow for different formatting of different
sets of contributors. For example:

<list id="1">
<single_prefix></single_prefix>
<multi_prefix></multi_prefix>
<corporate>{%Corporate%}</corporate>
<first_person>{%Last|First%}{ %First:ap%}{ %Middle:ap%}</
first_person>
<other_persons>{%Last|First%}{ %First:ap%}{ %Middle:ap%}</
other_persons>
<separator_between_if_two> and </separator_between_if_two>
<separator_between_if_more_than_two>, </
separator_between_if_more_than_two>
<separator_before_last>, and </separator_before_last>
<max_number_of_persons_to_display>10</
max_number_of_persons_to_display>
<number_of_persons_to_display_if_more_than_max>9</
number_of_persons_to_display_if_more_than_max>
<overflow>, et al.</overflow>
<single_suffix></single_suffix>
<multi_suffix></multi_suffix>
</list>

<list id="2">
<single_prefix></single_prefix>
<multi_prefix></multi_prefix>
<corporate>{%Corporate%}</corporate>
<first_person>{%First:ap%}{ %Middle:ap%}{ %Last%}</
first_person>
<other_persons>{%First:ap%}{ %Middle:ap%}{ %Last%}</
other_persons>
<separator_between_if_two> and </separator_between_if_two>
<separator_between_if_more_than_two>, </
separator_between_if_more_than_two>
<separator_before_last>, and </separator_before_last>
<max_number_of_persons_to_display>10</
max_number_of_persons_to_display>
<number_of_persons_to_display_if_more_than_max>9</
number_of_persons_to_display_if_more_than_max>
<overflow>, et al.</overflow>
<single_suffix> (Ed.)</single_suffix>
<multi_suffix> (Eds.)</multi_suffix>
</list>

The first list would put a contributors last name first, while the
second one does it the other way around. Also, the second one adds
' (Ed.)' or ' (Eds.)' after the contributor(s). So this would be used
to identify editors rather than common authors.


Thank you very much for all your help. Best wishes, Roberto



"p0" wrote:
On 2 nov, 15:20, Roberto <Robe...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Dear Yves,

you are very kind and helpful. I am starting to understand now. Let me be
clearer about what I am trying to do:

- suppress brackets in thecitationformat;

This is easy. Look for "b:FirstAuthor" and "b:LastAuthor". The former
is used to indicate what to do in front of the in-textcitationwhile
the latter indicates what to do after thecitation.

For example for theAPAstyle (APA.xsl), you have the following pieces
of code:

  <xsl:if test="msxsl:node-set($ListPopulatedWithMain)/b:Citation/
b:FirstAuthor">
    <xsl:call-template name="templ_prop_OpenBracket"/>
  </xsl:if>

  ...

  <xsl:if test="/b:Citation/b:LastAuthor">
    <xsl:call-template name="templ_prop_CloseBracket"/>
  </xsl:if>

  ...

  <xsl:if test="not(/b:Citation/b:LastAuthor)">
    <xsl:call-template name="templ_prop_GroupSeparator"/>
  </xsl:if>

The first one indicates that the result of "templ_prop_OpenBracket"
should be displayed in front of thecitation. If you want something
else, you can just replace that line by an xsl:text element. So if you
would want a square bracket, you would change it into:

  <xsl:if test="msxsl:node-set($ListPopulatedWithMain)/b:Citation/
b:FirstAuthor">
    <xsl:text>[</xsl:text>
  </xsl:if>

or if you don't want anything, you can just leave it blank:

  <xsl:if test="msxsl:node-set($ListPopulatedWithMain)/b:Citation/
b:FirstAuthor">
  </xsl:if>

The second one indicates that at the end of thecitationthe result of
"templ_prop_CloseBracket" should be displayed. The third and last one,
contains a "not" instruction. Basically, it tells what to do if this
is not the lastcitationin a group. For example if you would have
[firstcitation; secondcitation], then the third one would take care
of displaying "; " between the two citations.

- replace "." by "," in thebibliography; (the p element after <xsl:when
test="b:Bibliography">, I believe)

This is a lot harder as there might be dozens of dots which need
replacement. You would have to tell me the exact style and where to
change the dot to a comma. If there are no name abbreviations with
dots, and you are sure that every dot can be replaced with a comma,
you can wrap everything in the p element inside a variable and execute
a simple translate on it:

<xsl:element name="p">
   <!-- Some attribute stuff -->

   <xsl:variable name="dotted">
      <!-- All of the original code with exception of the above
attribute stuff -->
   </xsl:variable>

   <!-- Replace all the dots with a comma -->
   <xsl:value-of select="translate($dotted, '.', ',')/>

</xsl:element>

- change or suppress inverted commas around titles in thebibliography;

It would depend on the style you are using, but this is probably just
removing a call template function or two.

- possibly change the order of elements in thebibliography.

This is doable, but once you start doing all that, you would have to
ask yourself if it wouldn't be a lot easier to just write your own
style from scratch rather than having to find out how the data is
handled to start with.

And similar editing of the output. I was looking by these "connecting"
elements by the search option, by could not find them (maybe they are
replaced by some variable name). Maybe just a basic reference guide of xlst
instructions could help in finding the right code bits. Would you suggest any?

I'm not sure what you mean by 'connecting elements'. The logic of what
to put between elements depends on what is available and what isn't.
For example, one could have something like this:
  Title. City: Publisher, Year.

What if Publisher would be missing? There could be several options:
  Title. City: Year.
  Title. City, Year.
  Title. City. Year.

The entire code is nothing more than a huge bunch of xslt "if"
operations: if the City element is available and the Year element is
available but the Publisher element is not, then display the "." as a
separator. The very first style I wrote (http://www.codeplex.com/
bibliography/Release/ProjectReleases.aspx?ReleaseId=15365) uses this
technique. I got rid of this in later styles as I found it rather hard
to keep track of which elements were available and which were not.

http://www.w3schools.com/xsl/xsl_intro.aspoffers a basic introduction
to XSLT. I think that if you understand how the following elements
work, you can understand 90% of the styles: <xsl:if>, <xsl:choose>
(which is just if-else if - else), <xsl:variable> (storing a
variable), <xsl:template> (similar to a VBA function), <xsl:call-
template> (calling the function), <xsl:value-of> (displaying the
result of a variable). The only tricky thing about XSLT is that
variables can only get a value once.

Thank you again and I hope I am not profiting too much of your patience.

Best wishes.

"p0" wrote:
If what you want to change is only something small, I might be able to
help you.

Microsoft missed out on a great opportunity by making the XSLTs so
complex. What I tried to do with BibWord is make the styles less
complex and easier to manipulate/adjust. In time I will probably
convert the existing styles as to make them easier accessible.

"All"citationformatting related code in the Microsoft stylesheets is
located between a pair of tags looking like this:

  <xsl:when test="b:Citation">     <= only one of those
    ...
  </xsl:when>   <= dozens of those, make sure you have the matching
one

If you look inside this code part, you will see that it generates HTML
which is returned to Word:

  <html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://
www.w3.org/TR/REC-html40">
    <head>
    </head>
    <body>
    ...
      <xsl:element name="p">

      </xsl:element>
    </body>
  </html>

It's the part between the p element that is important to you. It might
look overly complex, but if you want something simple to display like
tag or reference order, it only takes a couple of lines to do so.

Yves

On 2 nov, 00:10, Roberto <Robe...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Dear Yves,

thank you very much for your reply. Indeed, in the meantime, since my post,
I had got across both pages. You are right when you say that they are
"simple" xlst files. I have been trying to figure out for a while which are
the basic elements of the code, but I got lost. I will try harder.. I would
only like to change the format of thecitation, of course, and I thought I
just could change an existing style. However, I could not find the same
structure of your BibWord in the MS styles. I think they are using some sort
of variable setting at the outset of the file, but I cannot decipher it, so
far. I do not want to become a developer for this. Maybe I will have to live
with what MS gives us! Thank you again and best wishes.

"p0" wrote:
On 1 nov, 18:48, Roberto <Robe...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I am looking for a way to modify existing or add newbibliographystyles to
Word 2007. Does anybody know how to do it? Any help would be greatly
appreciated. Thank you.

Word 2007bibliographystyles are "simple" xslt files. They are
located in <word 2007 directory>\Bibliography\Style and carry names
such asAPA.xsl and GB.xsl. You can edit them with any text editor.
They look rather complex at first glance but you have to keep in mind
that for each of this styles, almost half the code is never used and
is a leftover from a 'common' template. Microsoft forgot to do a lot
of cleaning up before releasing the styles.

If you want to create new ones from scratch, the following blogposting
might be of interest:http://blogs.msdn.com/microsoft_office_word/archive/2007/12/14/biblio...

Alternatively, you might want to check outhttp://www.codeplex.com/bibliography
.. It's a small site I maintain containing some information and tools
which can help creating/manipulating Word 2007bibliographystyles. It
also contains some styles I wrote.

Yves
.



Relevant Pages