Bibliographies in Word 2007

R

Roberto

I am looking for a way to modify existing or add new bibliography styles to
Word 2007. Does anybody know how to do it? Any help would be greatly
appreciated. Thank you.
 
P

p0

I am looking for a way to modify existing or add new bibliography styles to
Word 2007. Does anybody know how to do it? Any help would be greatly
appreciated. Thank you.

Word 2007 bibliography styles are "simple" xslt files. They are
located in <word 2007 directory>\Bibliography\Style and carry names
such as APA.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/bibliography-citations-1011.aspx

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

Yves
 
R

Roberto

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 the citation, 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.
 
P

p0

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" citation formatting 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:eek:="urn:schemas-microsoft-com:eek:ffice:eek:ffice"
xmlns:w="urn:schemas-microsoft-com:eek:ffice: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
 
R

Roberto

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 the citation format;
- replace "." by "," in the bibliography; (the p element after <xsl:when
test="b:Bibliography">, I believe)
- change or suppress inverted commas around titles in the bibliography;
- possibly change the order of elements in the bibliography.

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?

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

Best wishes.
 
P

p0

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-text citation while
the latter indicates what to do after the citation.

For example for the APA style (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 the citation. 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 the citation the 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 last citation in a group. For example if you would have
[first citation; second citation], 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, '.', ',')/>

- 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 suggestany?

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.asp offers 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.
 
R

Roberto

Thank you so much Yves, I will have to become a "developer", in the end. I
will keep track of your posts on codeplex. All the best.

p0 said:
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-text citation while
the latter indicates what to do after the citation.

For example for the APA style (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 the citation. 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 the citation the 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 last citation in a group. For example if you would have
[first citation; second citation], 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, '.', ',')/>

- 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.asp offers 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.
 
R

Roberto

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 for bibliography but I can get neither italics nor
bold, and I cannot find the error.

<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?

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

p0 said:
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-text citation while
the latter indicates what to do after the citation.

For example for the APA style (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 the citation. 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 the citation the 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 last citation in a group. For example if you would have
[first citation; second citation], 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, '.', ',')/>

- 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.asp offers 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.
 
P

p0

See my comments inline.

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

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



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, '.', ',')/>
It would depend on the style you are using, but this is probably just
removing a call template function or two.
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.
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.
 
P

p0

I forgot the ";" after the "&gt" in the example:

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

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

See my comments inline.

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

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 thebibliographyelement, 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 said:
Dear Yves,
you are very kind and helpful. I am starting to understand now. Letme 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 guideof 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.aspoffersa 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.
:
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 stylesheetsis
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
 
R

Roberto

Dear Yves,

I would have a final question (hopefully):

with your template, is it possible to use the Word 2007 pop-up dialogue box
for citations, where you can modify the citation to delete name, title, and
year and add specific pages to the citation?

I would be very interested to add pages for quotations, other than those in
the bibliography (%Pages%), like that: (Author Year, SpecificPages).

Thank you for your help and best wishes. I hope I will not disturb you again.

p0 said:
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-text citation while
the latter indicates what to do after the citation.

For example for the APA style (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 the citation. 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 the citation the 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 last citation in a group. For example if you would have
[first citation; second citation], 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, '.', ',')/>

- 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.asp offers 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.
 
P

p0

Yes and no.

The blocking of the author, title and year is done by the content of
noauthor, notitle, and noyear elements under the citation element
(section 3.4 of the help):

<citation>
<noauthor>-Artist-Author-BookAuthor-Compiler-Composer-Conductor-
Counsel-Director-Editor-Interviewee-Interviewer-Inventor-Performer-
ProducerName-Translator-Writer-</noauthor>
<notitle>-Title-AlbumTitle-BookTitle-BroadcastTitle-
InternetSiteTitle-PeriodicalTitle-PublicationTitle-ShortTitle-</
notitle>
<noyear>-Year-YearAccessed-"n.d."-</noyear>
...
</citation>

The above code is already in the template by default. You can of
course add or remove fields from those lists to your own liking.

In the current release, the following parameters are hardcoded:
PagePrefix (\f switch)
PageSuffix (\s switch)
Pages (\p switch)

You can find them in the "format-citation" template in the code. Their
current layout is:

[PagePrefix]CITATION[Pages][PageSuffix]

Where non of them have any specific prefixes. That is, you would have
to enter ", p. 5" if you wanted the comma and the page number prefix
to display and not just "5". The Volume parameter (\v switch) is
currently not support. So I you don't like that layout, you could try
to change it in format-citation. But I have a better solution.

You can try the latest version which I haven't put up as a release
yet. It fixes two small bugs in the current release and introduces
four new variables to play with: CitationPages (\p switch),
CitationPrefix (\f switch), CitationSuffix (\s switch) and
CitationVolume (\v switch). You can find the source template
(including an example on how to use the new variables) at:
http://www.codeplex.com/bibliograph...bliography/BibWord/Template&changeSetId=17707

Depending on when I find the time (which could be even today), the
above code, along with a few new extras, will be put up as a release
anyway. So it should be safe to use.

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



Dear Yves,

I would have a final question (hopefully):

with your template, is it possible to use the Word 2007 pop-up dialogue box
for citations, where you can modify the citation to delete name, title, and
year and add specific pages to the citation?

I would be very interested to add pages for quotations, other than those in
the bibliography (%Pages%), like that: (Author Year, SpecificPages).

Thank you for your help and best wishes. I hope I will not disturb you again.



This is easy. Look for "b:FirstAuthor" and "b:LastAuthor". The former
is used to indicate what to do in front of the in-text citation while
the latter indicates what to do after the citation.
For example for the APA style (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 the citation. 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 the citation the 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 last citation in a group. For example if you would have
[first citation; second citation], 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, '.', ',')/>
It would depend on the style you are using, but this is probably just
removing a call template function or two.
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.
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top