XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: constructing an element with an element's content based on thecontent of sibling element

Hi there Dana, Syd,

I noticed your message on XML-DEV as it sounded like a problem I'd encountered while mapping ONIX 3.0 to another schema (www.lido-schema.org if you're interested).

Sure enough, it was indeed ONIX-related. Well, I'm working here at the company that maintains and develops the ONIX standards, and I've grown quite familiar with all things ONIX-mapping (have you seen http://www.editeur.org/96/ONIX-and-MARC21/ by the way? Maybe you're working on something similar?).

Anyway, if you'd like to compare notes on this or any related issues, please feel free to drop us a line. We are always interested to hear what people are doing with our standards, offer help and maybe learn something too.

Best wishes,

Michael Hopwood
Linked Heritage Project Lead
EDItEUR
United House, North  Road
London N7 9DP
UK

Tel: +44 20 7503 6418
Mob: +44 7811 591036
Skype: michael.hopwood.editeur
http://www.linkedheritage.org/
http://editeur.org/

The information contained in this e-mail is confidential and may be privileged. It is intended for the addressee only. If you are not the intended recipient, please inform the sender and delete this e-mail immediately. The contents of this e-mail must not be disclosed or copied without the sender's consent. We cannot accept any responsibility for viruses, so please scan all attachments. The statements and opinions expressed in this message are those of the author and do not necessarily reflect those of the company.

EDItEUR Limited is a company limited by guarantee, registered in England no 2994705. Registered Office:
United House, North Road, London N7 9DP, United Kingdom



-----Original Message-----
From: xsl-list-digest-help@lists.mulberrytech.com [mailto:xsl-list-digest-help@lists.mulberrytech.com]
Sent: 12 June 2012 06:10
To: xsl-list@lists.mulberrytech.com
Subject: xsl-list Digest 12 Jun 2012 05:10:01 -0000 Issue 2852

xsl-list Digest 12 Jun 2012 05:10:01 -0000 Issue 2852

Topics (messages 62316 through 62331):

Re: constructing an element with an element's content based on the content of sibling element
        62316 by: Syd Bauman
        62329 by: Dana Pearson
        62330 by: Syd Bauman
        62331 by: Dana Pearson

Re: Keys, IDs lookup tables.
        62317 by: daniel whitney

Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)
        62318 by: Michele R Combs
        62319 by: Ihe Onwuka
        62321 by: Michele R Combs
        62322 by: Wendell Piez
        62323 by: G. Ken Holman
        62324 by: Ihe Onwuka

Re: analyze-string help?
        62320 by: Graydon

Re: Trying to use fo:page-number-citation to set the initial-page-number of the next page-sequence
        62325 by: Underwood Michelle
        62326 by: G. Ken Holman

pass variable length parameters to java function
        62327 by: Ming Yu
        62328 by: Michael Kay

Administrivia:

To subscribe to the digest, e-mail:
        <xsl-list-digest-subscribe@lists.mulberrytech.com>

To unsubscribe from the digest, e-mail:
        <xsl-list-digest-unsubscribe@lists.mulberrytech.com>

To post to the list, e-mail:
        <xsl-list@lists.mulberrytech.com>


----------------------------------------------------------------------
Date: Mon, 11 Jun 2012 03:05:46 -0400
To: xsl-list@lists.mulberrytech.com
From: Syd Bauman <Syd_Bauman@Brown.edu>
Subject: Re: [xsl] constructing an element with an element's content based on
 the content of sibling element
Message-ID: <20437.39114.811926.926379@emt.wwp.brown.edu>

You're welcome.

I'm beginning to suspect that, like many folks who come to XSLT from
procedural languages like Perl or C, you are using mostly "pull"
processing (get X, put it here; get Y, put it next ...) rather than
mostly "push" processing (whenever you hit an X, do this; whenever
you hit a Y, do that).

The code I sent presumed that your XSLT was busy processing the
*parent* of the <productidentifier> element (e.g. a <containeditem>,
<notforsale>, <product>, <relatedproduct>, or <set>) when you wanted
the ISBN spit out as a <controlfield>. If you're going to use
      <xsl:for-each select="productidentifier">
        <xsl:call-template name="isbn"/>
      </xsl:for-each>
then in the "isbn" template you're calling, the context node will be
the <productidentifier>. Thus to test for the existence of a <b221>
child element with the value '15', you test any one of the following,
which are equivalent
   self::productidentifier/child::b221 = '15'
   self::productidentifier/b221 = '15'
   ./child::b221 = '15'
   ./b221 = '15'
   b221 = '15'

So in the code you just posted,
> <xsl:template name="isbn" match="productidentifier">
>   <xsl:choose>
>    <xsl:when test="productidentifier/b221 = '15'">
>      <xsl:apply-templates select="productidentifier[b221='15']"/>

The template is being fired with a <productidentifier> as the current
node. So the test "productidentifier/b221" is asking to look at each
<b221> child of the <productidentifier> child of the currently being
processed <productidentifier>. Since there are no <productidentifier>
elements as children of the current <productidentifier>, the test can
never be true.

So you might try something like

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:marc="http://www.loc.gov/MARC21/slim"; version="2.0">

  <xsl:template match="/">
    <marc:pretend-wrapper-to-hold-multiple-records>
      <xsl:apply-templates select="wrapper/product"/>
    </marc:pretend-wrapper-to-hold-multiple-records>
  </xsl:template>

  <xsl:template match="product">
    <marc:record>
      <xsl:for-each select="productidentifier">
        <xsl:call-template name="isbn"/>
      </xsl:for-each>
    </marc:record>
  </xsl:template>

  <xsl:template name="isbn" match="productidentifier">
    <xsl:choose>
      <!-- first take care of "I am ISBN 13" case -->
      <xsl:when test="child::b221 = '15'">
        <controlfield tag="001">
          <xsl:text>ISBN13 = </xsl:text>
          <xsl:value-of select="b244"/>
        </controlfield>
      </xsl:when>
      <!-- then ignore case where I have a sibling that is ISBN 13 -->
      <xsl:when test="parent::*/child::productidentifier/child::b221 = '15'"/>
      <!-- no sibling ISBN 13, so use ISBN 10, if that's what I am -->
      <xsl:when test="child::b221 = '02'">
        <controlfield tag="001">
          <xsl:text>ISBN10 = </xsl:text>
          <xsl:value-of select="b244"/>
        </controlfield>
      </xsl:when>
      <xsl:otherwise>
        <xsl:message>Danger, Will Robinson! a 'productidentifier' that is confusing</xsl:message>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>

Although I personally prefer the previous version.

> Thanks very much for your reply, Syd.
>
> My apologies, I didn't search the XSL archive specifically, many of
> the results from my google search queries included the archive. I
> also poured over Kay's tomb for the functions not(), exists(),
> empty() (got really excited for a moment with element
> -available()).
>
> My stylesheet has nearly 1300 lines of code transforming ONIX for
> Books 2.1 into MARCXML. I'm using XSLT 2.0 (use tokenize() not
> available in 1.0); Stylus Studio Enterprise edition 2010.
>
> In fact, the scenario for the need of an alternate ISBN is small
> but the variability of publisher encoding warrants this test I
> think.
>
> In place of the stylesheet segment in my OP, I substituted a
> call-template based on your reply. The main template of my
> stylesheet matches the product element with ONIXMessage as the
> context and I use call-template for the construction of 1XX, 7XX
> and 245 MARC fields given the complexity of those fields with
> respect to name and title elements in ONIX as well as punctuation
> in the MARCXML fields.
>
> Hadn't thought to use call-template here but also hadn't considered
> the predicates you offered, so I tried this based on your
> suggestion but get no controlfields at all. Wan't sure about the
> context of the value-of select paths, so tried value-of
> select="following-sibling::b244", too.
>
> <marc:record>
> .
> .
> <xsl:for-each select="productidentifier">
>   <xsl:call-template name="isbn"/>
> </xsl:for-each>
> .
> .
> </marc:record
>
> <xsl:template name="isbn" match="productidentifier">
>   <xsl:choose>
>    <xsl:when test="productidentifier/b221 = '15'">
>      <xsl:apply-templates select="productidentifier[b221='15']"/>
>     </xsl:when>
>     <xsl:otherwise>
>     <xsl:apply-templates select="productidentifier[b221='02']"/>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
>
> <xsl:template match="productidentifier[b221 eq '02']">
>   <controlfield tag="001">
>     <xsl:text>xyz</xsl:text>
>     <xsl:value-of select="b244"/>
>   </controlfield>
> </xsl:template>
>
> <xsl:template match="productidentifier[b221 eq '15']">
>   <controlfield tag="001">
>    <xsl:text>xyz</xsl:text>
>    <xsl:value-of select="b244"/>
>   </controlfield>
> </xsl:template>
>
> Most of my earlier efforts centered on the use of
> xsl:choose and xsl:otherwise.  All failed so think I'm
> lacking a basic understanding of an important XSLT
> concept.
>
> Tried attaching a file with 3 records with the variation of presence
> of different product identifiers but my message was rejected even
> though in a text file.

------------------------------

Date: Mon, 11 Jun 2012 19:41:13 -0500
To: xsl-list@lists.mulberrytech.com
From: Dana Pearson <dbpearsonmlis@gmail.com>
Subject: Re: [xsl] constructing an element with an element's content based on
 the content of sibling element
Message-ID: <CA+g3ULsnru4zjR=g6rs76GX0C2YBoCzt7oDiiC_guerTXJUhKQ@mail.gmail.com>

thanks so very much, Syd

don't yet understand how the empty xsl:when does it (although I've
used it before)...but works like a charm..

more study the only course

regards,
dana

--
Dana Pearson
dbpearsonmlis.com

------------------------------

Date: Mon, 11 Jun 2012 21:05:27 -0400
To: xsl-list@lists.mulberrytech.com
From: Syd Bauman <Syd_Bauman@Brown.edu>
Subject: Re: [xsl] constructing an element with an element's content based on
 the content of sibling element
Message-ID: <20438.38359.324821.958689@emt.wwp.brown.edu>

> don't yet understand how the empty xsl:when does it (although I've
> used it before)...but works like a charm..

Perhaps more intensive commenting will help:

  <!--
   We're going to hit this template several times in a row, once for
   each <productidentifier>. We want to print out the ISBN13 if there
   is one, and the ISBN10 if there is no ISBN13. So when we are
   called for a <productidentifier>, we have to figure out whether to
   generate output or not by looking at ourself and our siblings.
   * if we are the ISBN13 case, print out
   * if we are not the ISBN13 case, but one of our siblings is, then
     don't do anything (the ISBN13 will be printed when our sibling is
     matched by this very template)
   * if we are not the ISBN13 case, and none of our siblings are
     ISBN13, and we are the ISBN10, then print it out
   * if we are not the ISBN13 case, and none of our siblings are
     ISBN13, but we are not the ISBN10, then a warning message
  -->
  <xsl:template name="isbn" match="productidentifier">
    <xsl:choose>
      <!-- first take care of the "I am ISBN 13" case -->
      <xsl:when test="child::b221 = '15'">
        <controlfield tag="001">
          <xsl:text>ISBN13 = </xsl:text>
          <xsl:value-of select="b244"/>
        </controlfield>
      </xsl:when>
      <!-- if we've gotten this far, this is not the "I am ISBN 13" case -->
      <!-- test to see if we have a sibling that is hte ISBN 13 case;
      if so, do nothing, as this template will do the work (above) when
      it hits that sibling -->
      <xsl:when test="parent::*/child::productidentifier/child::b221 = '15'"/>
      <!-- we've gotten this far, so there is no sibling ISBN 13;
      so use ISBN 10, if that's what I am -->
      <xsl:when test="child::b221 = '02'">
        <controlfield tag="001">
          <xsl:text>ISBN10 = </xsl:text>
          <xsl:value-of select="b244"/>
        </controlfield>
      </xsl:when>
      <xsl:otherwise>
        <xsl:message>Danger, Will Robinson! a 'productidentifier' that is confusing</xsl:message>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

------------------------------

Date: Mon, 11 Jun 2012 20:20:58 -0500
To: xsl-list@lists.mulberrytech.com
From: Dana Pearson <dbpearsonmlis@gmail.com>
Subject: Re: [xsl] constructing an element with an element's content based on
 the content of sibling element
Message-ID: <CA+g3ULuxZsNebLnwdO_vBkKZhY3092Z-NasfvOUKA7AnNMUp9Q@mail.gmail.com>

actually that helps a lot...my problem is not with a procedural
programming past but virtually no programming past...although a
javascript course in graduate school provided practice in pseudocode..

this is something that I can use elsewhere in my
stylesheet....contributor names come in 4 different elements and
dozens upon dozens of type...

thanks again..

regards,
dana

On Mon, Jun 11, 2012 at 8:05 PM, Syd Bauman <Syd_Bauman@brown.edu> wrote:
>> don't yet understand how the empty xsl:when does it (although I've
>> used it before)...but works like a charm..
>
> Perhaps more intensive commenting will help:
>
> =A0<!--
> =A0 We're going to hit this template several times in a row, once for
> =A0 each <productidentifier>. We want to print out the ISBN13 if there
> =A0 is one, and the ISBN10 if there is no ISBN13. So when we are
> =A0 called for a <productidentifier>, we have to figure out whether to
> =A0 generate output or not by looking at ourself and our siblings.
> =A0 * if we are the ISBN13 case, print out
> =A0 * if we are not the ISBN13 case, but one of our siblings is, then
> =A0 =A0 don't do anything (the ISBN13 will be printed when our sibling is
> =A0 =A0 matched by this very template)
> =A0 * if we are not the ISBN13 case, and none of our siblings are
> =A0 =A0 ISBN13, and we are the ISBN10, then print it out
> =A0 * if we are not the ISBN13 case, and none of our siblings are
> =A0 =A0 ISBN13, but we are not the ISBN10, then a warning message
> =A0-->
> =A0<xsl:template name=3D"isbn" match=3D"productidentifier">
> =A0 =A0<xsl:choose>
> =A0 =A0 =A0<!-- first take care of the "I am ISBN 13" case -->
> =A0 =A0 =A0<xsl:when test=3D"child::b221 =3D '15'">
> =A0 =A0 =A0 =A0<controlfield tag=3D"001">
> =A0 =A0 =A0 =A0 =A0<xsl:text>ISBN13 =3D </xsl:text>
> =A0 =A0 =A0 =A0 =A0<xsl:value-of select=3D"b244"/>
> =A0 =A0 =A0 =A0</controlfield>
> =A0 =A0 =A0</xsl:when>
> =A0 =A0 =A0<!-- if we've gotten this far, this is not the "I am ISBN 13" =
case -->
> =A0 =A0 =A0<!-- test to see if we have a sibling that is hte ISBN 13 case=
;
> =A0 =A0 =A0if so, do nothing, as this template will do the work (above) w=
hen
> =A0 =A0 =A0it hits that sibling -->
> =A0 =A0 =A0<xsl:when test=3D"parent::*/child::productidentifier/child::b2=
21 =3D '15'"/>
> =A0 =A0 =A0<!-- we've gotten this far, so there is no sibling ISBN 13;
> =A0 =A0 =A0so use ISBN 10, if that's what I am -->
> =A0 =A0 =A0<xsl:when test=3D"child::b221 =3D '02'">
> =A0 =A0 =A0 =A0<controlfield tag=3D"001">
> =A0 =A0 =A0 =A0 =A0<xsl:text>ISBN10 =3D </xsl:text>
> =A0 =A0 =A0 =A0 =A0<xsl:value-of select=3D"b244"/>
> =A0 =A0 =A0 =A0</controlfield>
> =A0 =A0 =A0</xsl:when>
> =A0 =A0 =A0<xsl:otherwise>
> =A0 =A0 =A0 =A0<xsl:message>Danger, Will Robinson! a 'productidentifier' =
that is confusing</xsl:message>
> =A0 =A0 =A0</xsl:otherwise>
> =A0 =A0</xsl:choose>
> =A0</xsl:template>
>
> --~------------------------------------------------------------------
> XSL-List info and archive: =A0http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
> --~--
>

--=20
Dana Pearson
dbpearsonmlis.com

------------------------------

Date: Mon, 11 Jun 2012 11:29:11 -0400
To: xsl-list@lists.mulberrytech.com
From: daniel whitney <dbf.whitney@gmail.com>
Subject: Re: [xsl] Re: Keys, IDs lookup tables.
Message-ID: <CA+G+HH5c_dYpZ2vxhUBePcjpRXN+TP4HqNXJ2HNgJAJzcaTdjw@mail.gmail.com>

Thanks, Wendell. Works great. Dan

On Wed, Jun 6, 2012 at 6:04 PM, Wendell Piez <wapiez@mulberrytech.com> wrot=
e:
> Daniel,
>
>
> On 6/6/2012 3:31 PM, daniel whitney wrote:
>>
>> OK so I came up with a solution for Part 2 of my question. Not sure if
>> it's the ideal, but it works:
>>
>> Would Part 1 have a similar solution? Would I store the "lookup"
>> portion in a global variable and just call that again and again?
>
>
> Basically, yes, although you will get closer to your ideal of clarity, gr=
ace
> and maintainability if you refactor with templates. When doing so, you ca=
n
> pass parameters to retain context.
>
> So something like:
>
> <xsl:template match=3D"financialgroup">
>
> =A0<tr>
> =A0 =A0<td>
> =A0 =A0 =A0<xsl:value-of select=3D"key('legend', @financiallegendcode)"/>
> =A0 =A0</td>
> =A0 =A0<xsl:apply-templates select=3D"ancestor::financials/perioddate/per=
iod"
> =A0 =A0 =A0mode=3D"period-cell">
> =A0 =A0 =A0<xsl:with-param name=3D"fgroup" select=3D"."/>
> =A0 =A0</xsl:apply-templates>
> =A0</tr>
> </xsl:template>
>
> ... and to receive the call:
>
> <xsl:template match=3D"period" mode=3D"period-cell">
> =A0<xsl:param name=3D"fgroup" as=3D"element(financialgroup)"/>
>
> =A0<xsl:variable name=3D"idBase" select=3D"@id"/>
> =A0<td>
> =A0 =A0<xsl:value-of
> =A0 =A0 =A0select=3D"($fgroup/financial[@periodref=3D$idBase],'....')[1]"=
/>
> =A0</td>
> </xsl:template>
>
> Obviously the details aren't worked out here, and note also I'm using an
> XPath 2.0 idiom to provide the fallback value when the particular
> 'financialgroup' element has no 'financial' value for the period.
>
> This also fixes a bug in your code where every period covered is assigned
> all values for all of them (or the first of them, if run as XSLT 1.0).
>
> I hope this helps,
> Wendell
>
>
>> <xsl:template match=3D"financialgroup">
>> <xsl:variable name=3D"currentFinancial" select=3D"financial"/>
>> <tr>
>> <td><xsl:value-of select=3D"key('legend', @financiallegendcode)"/></td>
>> <xsl:for-each select=3D"ancestor::financials/perioddata/period">
>> <xsl:variable name=3D"idBase" select=3D"@id"/>
>> <td align=3D"right">
>> <xsl:choose>
>> <xsl:when test=3D"$currentFinancial/@periodref=3D$idBase">
>> <xsl:value-of select=3D"$currentFinancial[@periodref=3D$idBase]"/>
>> </xsl:when>
>> <xsl:otherwise>
>> <xsl:text>....</xsl:text>
>> </xsl:otherwise>
>> </xsl:choose>
>> </td>
>> </xsl:for-each>
>> </tr>
>> </xsl:template>
>>
>>
>> On Wed, Jun 6, 2012 at 10:41 AM, daniel whitney<dbf.whitney@gmail.com>
>> =A0wrote:
>>>
>>> Hi I'm having problems trying to figure out how to accomplish this and
>>> what the best strategy might be.
>>>
>>> It's a 2 part problem. The first with keys. The second with ID/IDREF.
>>>
>>> 1. I have an xml file with a "lookup" table at the top
>>> (presentation/financiallegend). I want to output, as html, the
>>> "longname" element in a table cell whether it exists in the "data" or
>>> not. If it does exist in the data then the following =A0cells will
>>> contain the financial data. If it doesn't exist, the following cells
>>> would just be empty. My XSL file outputs the rows with financial data
>>> correctly, but does not include rows where only the "longname" exists
>>> (no financial data).
>>>
>>> 2. The header row of the table is a row of dates, each with a unique
>>> id. The subequent rows are financial data that have to align with the
>>> corresponding date id. The financial data include refs to their
>>> corresponding date ids, but of course there might be ids without a
>>> corresponding idref. So I have no idea how get the columns to align
>>> correctly.
>>>
>>> This is a very basic example. The file itself has dozens of lookup
>>> tables (not too many IDs). So I'm wondering how to accomplisth this
>>> and what is the best strategy to keep things as clean and simple as
>>> possible.
>>>
>>> Does having a schema contribute to the simplicity of the XSL somehow,
>>> in regards to keys? Or are they essentially separate entities?
>>>
>>> Any help is, of course, greatly appreciated.
>>>
>>> Thanks,
>>>
>>> Dan
>>>
>>> XML file:
>>>
>>> <?xml version=3D"1.0" encoding=3D"windows-1252"?>
>>> <requesteddata>
>>> <presentation>
>>> <financiallegend>
>>> <code>60.00</code>
>>> <longname>Revenue - Operating/Total</longname>
>>> </financiallegend>
>>> <financiallegend>
>>> <code>29.00</code>
>>> <longname>Total Assets</longname>
>>> </financiallegend>
>>> <financiallegend>
>>> <code>73.00</code>
>>> <longname>Pre-Tax Income</longname>
>>> </financiallegend>
>>> <financiallegend>
>>> <code>2.00</code>
>>> <longname>Made-up filler</longname>
>>> </financiallegend>
>>> <financiallegend>
>>> <code>82.00</code>
>>> <longname>Net Income</longname>
>>> </financiallegend>
>>> </presentation>
>>> <company>
>>> <fpid>154</fpid>
>>> <legal>High River Gold Mines Ltd.</legal>
>>> <financials>
>>> <perioddata>
>>> <period id=3D"154_2011-12-31_A_A_414785">
>>> <perioddate>2011-12-31</perioddate>
>>> <reporttype code=3D"A">As reported</reporttype>
>>> </period>
>>> <period id=3D"154_2010-12-31_A_R_414804">
>>> <perioddate>2010-12-31</perioddate>
>>> <reporttype code=3D"R">Restated</reporttype>
>>> </period>
>>> <period id=3D"154_2009-12-31_A_A_414700">
>>> <perioddate>2010-12-31</perioddate>
>>> <reporttype code=3D"A">As reported</reporttype>
>>> </period>
>>> </perioddata>
>>> <financialdata>
>>> <financialgroup financiallegendcode=3D"29.00" legend=3D"Total Assets">
>>> <financial periodref=3D"154_2011-12-31_A_A_414785">1007827</financial>
>>> <financial periodref=3D"154_2010-12-31_A_R_414804">1102209</financial>
>>> <financial periodref=3D"154_2009-12-31_A_A_414700">209987</financial>
>>> </financialgroup>
>>> <financialgroup financiallegendcode=3D"73.00" legend=3D"Pre-Tax Income"=
>
>>> <financial periodref=3D"154_2011-12-31_A_A_414785">231673</financial>
>>> <financial periodref=3D"154_2009-12-31_A_A_414700">191115</financial>
>>> </financialgroup>
>>> <financialgroup financiallegendcode=3D"82.00" legend=3D"Net Income">
>>> <financial periodref=3D"154_2010-12-31_A_R_414804">28999</financial>
>>> <financial periodref=3D"154_2009-12-31_A_A_414700">191203</financial>
>>> </financialgroup>
>>> <financialgroup financiallegendcode=3D"60.00" legend=3D"Revenue -
>>> Operating/Total">
>>> <financial periodref=3D"154_2011-12-31_A_A_414785">573949</financial>
>>> <financial periodref=3D"154_2010-12-31_A_R_414804">529765</financial>
>>> <financial periodref=3D"154_2009-12-31_A_A_414700">447635</financial>
>>> </financialgroup>
>>> </financialdata>
>>> </financials>
>>> </company>
>>> <company>
>>> <fpid>11</fpid>
>>> <legal>Barrick Gold</legal>
>>> <financials>
>>> <perioddata>
>>> <period id=3D"11_2011-12-31_A_A_1">
>>> <perioddate>2011-12-31</perioddate>
>>> <reporttype code=3D"A">As reported</reporttype>
>>> </period>
>>> <period id=3D"11_2010-12-31_A_A_2">
>>> <perioddate>2010-12-31</perioddate>
>>> <reporttype code=3D"A">As reported</reporttype>
>>> </period>
>>> </perioddata>
>>> <financialdata>
>>> <financialgroup financiallegendcode=3D"29.00" legend=3D"Total Assets">
>>> <financial periodref=3D"11_2011-12-31_A_A_1">1007827</financial>
>>> <financial periodref=3D"11_2010-12-31_A_A_2">1102209</financial>
>>> </financialgroup>
>>> <financialgroup financiallegendcode=3D"82.00" legend=3D"Net Income">
>>> <financial periodref=3D"11_2010-12-31_A_A_2">191203</financial>
>>> </financialgroup>
>>> <financialgroup financiallegendcode=3D"60.00" legend=3D"Revenue -
>>> Operating/Total">
>>> <financial periodref=3D"11_2011-12-31_A_A_1">573949</financial>
>>> </financialgroup>
>>> </financialdata>
>>> </financials>
>>> </company>
>>> </requesteddata>
>>>
>>>
>>> XSL file:
>>>
>>> <?xml version=3D"1.0" encoding=3D"windows-1252"?>
>>> <xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform";
>>> version=3D"2.0">
>>> <xsl:output method=3D"html" indent=3D"yes" encoding=3D"windows-1252"/>
>>> <xsl:key name=3D"legend" match=3D"longname" use=3D"../code"/>
>>>
>>> <xsl:template match=3D"requesteddata">
>>> <xsl:for-each select=3D"company">
>>> <table border=3D"1">
>>> <tr>
>>> <td colspan=3D"4">
>>> <xsl:value-of select=3D"legal"/>
>>> </td>
>>> </tr>
>>> <xsl:apply-templates select=3D"financials/perioddata"/>
>>> <xsl:apply-templates
>>> select=3D"financials/financialdata/financialgroup[key('legend',
>>> @financiallegendcode)]"/>
>>> </table>
>>> </xsl:for-each>
>>> </xsl:template>
>>>
>>> <xsl:template match=3D"perioddata">
>>> <tr>
>>> <td>&#160;</td>
>>> <xsl:for-each select=3D"period">
>>> <td>
>>> <xsl:value-of select=3D"perioddate"/><xsl:text> =A0-
>>> </xsl:text><xsl:value-of select=3D"reporttype"/>
>>> </td>
>>> </xsl:for-each>
>>> </tr>
>>> </xsl:template>
>>>
>>> <xsl:template match=3D"financials/financialdata/financialgroup">
>>> <tr>
>>> <td><xsl:value-of select=3D"key('legend', @financiallegendcode)"/></td>
>>> <xsl:for-each select=3D"financial">
>>> <td><xsl:value-of select=3D"."/></td>
>>> </xsl:for-each>
>>> </tr>
>>> </xsl:template>
>>>
>>> <xsl:template name=3D"presentation"/>
>>> </xsl:stylesheet>
>>>
>>> Output HTML example:
>>>
>>> <table border=3D"1">
>>> <tr>
>>> <td colspan=3D"4">High River Gold Mines Ltd.</td>
>>> </tr>
>>> <tr>
>>> <td>&#160;</td><td>2011-12-31 - As Reported</td><td>2010-12-31 -
>>> Restated</td><td>2009-12-31 - As Reported</td>
>>> </tr>
>>> <tr>
>>> <td>Revenue -
>>> Operating/Total</td><td>573949</td><td>529765</td><td>447635</td>
>>> </tr>
>>> <tr>
>>> <td>Total Assets</td><td>1007827</td><td>1102209</td><td>209987</td>
>>> </tr>
>>> <tr>
>>> <td>Pre-Tax Income</td><td>231673</td><td>&#160;</td><td>191115</td>
>>> </tr>
>>> <tr>
>>> <td>Made-up filler</td><td>&#160;</td><td>&#160;</td><td>&#160;</td>
>>> </tr>
>>> <tr>
>>> <td>Net Income</td><td>&#160;</td><td>28999</td><td>191203</td>
>>> </tr>
>>> </table>
>>>
>>> <table border=3D"1">
>>> <tr>
>>> <td colspan=3D"4">Barrick Gold</td>
>>> </tr>
>>> <tr>
>>> <td>&#160;</td><td>2011-12-31 - As Reported</td><td>2010-12-31 - As
>>> Reported</td>
>>> </tr>
>>> <tr>
>>> <td>Revenue - Operating/Total</td><td>573949</td><td>&#160;</td>
>>> </tr>
>>> <tr>
>>> <td>Total Assets</td><td>1007827</td><td>1102209</td>
>>> </tr>
>>> <tr>
>>> <td>Pre-Tax Income</td><td>&#160;</td><td>&#160;</td>
>>> </tr>
>>> <tr>
>>> <td>Made-up filler</td><td>&#160;</td><td>&#160;</td>
>>> </tr>
>>> <tr>
>>> <td>Net Income</td><td>&#160;</td><td>191203</td>
>>> </tr>
>>> </table>
>
>
> --
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> Wendell Piez =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mailt=
o:wapiez@mulberrytech.com
> Mulberry Technologies, Inc. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://www.mul=
berrytech.com
> 17 West Jefferson Street =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Direct Ph=
one: 301/315-9635
> Suite 207 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0Phone: 301/315-9631
> Rockville, MD =A020850 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 Fax: 301/315-8285
> ----------------------------------------------------------------------
> =A0Mulberry Technologies: A Consultancy Specializing in SGML and XML
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> --~------------------------------------------------------------------
> XSL-List info and archive: =A0http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
> --~--
>

------------------------------

Date: Mon, 11 Jun 2012 16:01:24 +0000
To: "'xsl-list@lists.mulberrytech.com'" <xsl-list@lists.mulberrytech.com>
From: Michele R Combs <mrrothen@syr.edu>
Subject: Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)
Message-ID: <2FD713CF35B5A748AD77C21ECEF69AAA15BF46@SUEX10-mbx-05.ad.syr.edu>

I notice that you're using "mode" in this solution.  Can someone point me t=
o a good explanation of modes, with good examples?  I haven't worked much w=
ith them and am finding them a bit confusing.

Thanks

Michele

On Wed, Jun 6, 2012 at 6:04 PM, Wendell Piez <wapiez@mulberrytech.com> wrot=
e:
> Daniel,
>
>
> On 6/6/2012 3:31 PM, daniel whitney wrote:
>>
>> OK so I came up with a solution for Part 2 of my question. Not sure=20
>> if it's the ideal, but it works:
>>
>> Would Part 1 have a similar solution? Would I store the "lookup"
>> portion in a global variable and just call that again and again?
>
>
> Basically, yes, although you will get closer to your ideal of clarity,=20
> grace and maintainability if you refactor with templates. When doing=20
> so, you can pass parameters to retain context.
>
> So something like:
>
> <xsl:template match=3D"financialgroup">
>
> =A0<tr>
> =A0 =A0<td>
> =A0 =A0 =A0<xsl:value-of select=3D"key('legend', @financiallegendcode)"/>
> =A0 =A0</td>
> =A0 =A0<xsl:apply-templates select=3D"ancestor::financials/perioddate/per=
iod"
> =A0 =A0 =A0mode=3D"period-cell">
> =A0 =A0 =A0<xsl:with-param name=3D"fgroup" select=3D"."/>
> =A0 =A0</xsl:apply-templates>
> =A0</tr>
> </xsl:template>
>
> ... and to receive the call:
>
> <xsl:template match=3D"period" mode=3D"period-cell">
> =A0<xsl:param name=3D"fgroup" as=3D"element(financialgroup)"/>
>
> =A0<xsl:variable name=3D"idBase" select=3D"@id"/>
> =A0<td>
> =A0 =A0<xsl:value-of
> =A0 =A0 =A0select=3D"($fgroup/financial[@periodref=3D$idBase],'....')[1]"=
/>
> =A0</td>
> </xsl:template>
>
> Obviously the details aren't worked out here, and note also I'm using=20
> an XPath 2.0 idiom to provide the fallback value when the particular=20
> 'financialgroup' element has no 'financial' value for the period.
>
> This also fixes a bug in your code where every period covered is=20
> assigned all values for all of them (or the first of them, if run as XSLT=
 1.0).
>
> I hope this helps,
> Wendell
>
>
>> <xsl:template match=3D"financialgroup"> <xsl:variable=20
>> name=3D"currentFinancial" select=3D"financial"/> <tr> <td><xsl:value-of=
=20
>> select=3D"key('legend', @financiallegendcode)"/></td> <xsl:for-each=20
>> select=3D"ancestor::financials/perioddata/period">
>> <xsl:variable name=3D"idBase" select=3D"@id"/> <td align=3D"right">=20
>> <xsl:choose> <xsl:when test=3D"$currentFinancial/@periodref=3D$idBase">
>> <xsl:value-of select=3D"$currentFinancial[@periodref=3D$idBase]"/>
>> </xsl:when>
>> <xsl:otherwise>
>> <xsl:text>....</xsl:text>
>> </xsl:otherwise>
>> </xsl:choose>
>> </td>
>> </xsl:for-each>
>> </tr>
>> </xsl:template>
>>
>>
>> On Wed, Jun 6, 2012 at 10:41 AM, daniel=20
>> whitney<dbf.whitney@gmail.com>
>> =A0wrote:
>>>
>>> Hi I'm having problems trying to figure out how to accomplish this=20
>>> and what the best strategy might be.
>>>
>>> It's a 2 part problem. The first with keys. The second with ID/IDREF.
>>>
>>> 1. I have an xml file with a "lookup" table at the top=20
>>> (presentation/financiallegend). I want to output, as html, the=20
>>> "longname" element in a table cell whether it exists in the "data"=20
>>> or not. If it does exist in the data then the following =A0cells will=20
>>> contain the financial data. If it doesn't exist, the following cells=20
>>> would just be empty. My XSL file outputs the rows with financial=20
>>> data correctly, but does not include rows where only the "longname"=20
>>> exists (no financial data).
>>>
>>> 2. The header row of the table is a row of dates, each with a unique=20
>>> id. The subequent rows are financial data that have to align with=20
>>> the corresponding date id. The financial data include refs to their=20
>>> corresponding date ids, but of course there might be ids without a=20
>>> corresponding idref. So I have no idea how get the columns to align=20
>>> correctly.
>>>
>>> This is a very basic example. The file itself has dozens of lookup=20
>>> tables (not too many IDs). So I'm wondering how to accomplisth this=20
>>> and what is the best strategy to keep things as clean and simple as=20
>>> possible.
>>>
>>> Does having a schema contribute to the simplicity of the XSL=20
>>> somehow, in regards to keys? Or are they essentially separate entities?
>>>
>>> Any help is, of course, greatly appreciated.
>>>
>>> Thanks,
>>>
>>> Dan
>>>
>>> XML file:
>>>
>>> <?xml version=3D"1.0" encoding=3D"windows-1252"?> <requesteddata>=20
>>> <presentation> <financiallegend> <code>60.00</code>=20
>>> <longname>Revenue - Operating/Total</longname> </financiallegend>=20
>>> <financiallegend> <code>29.00</code> <longname>Total=20
>>> Assets</longname> </financiallegend> <financiallegend>=20
>>> <code>73.00</code> <longname>Pre-Tax Income</longname>=20
>>> </financiallegend> <financiallegend> <code>2.00</code>=20
>>> <longname>Made-up filler</longname> </financiallegend>=20
>>> <financiallegend> <code>82.00</code> <longname>Net Income</longname>=20
>>> </financiallegend> </presentation> <company> <fpid>154</fpid>=20
>>> <legal>High River Gold Mines Ltd.</legal> <financials> <perioddata>=20
>>> <period id=3D"154_2011-12-31_A_A_414785">=20
>>> <perioddate>2011-12-31</perioddate>
>>> <reporttype code=3D"A">As reported</reporttype> </period> <period=20
>>> id=3D"154_2010-12-31_A_R_414804"> <perioddate>2010-12-31</perioddate>
>>> <reporttype code=3D"R">Restated</reporttype> </period> <period=20
>>> id=3D"154_2009-12-31_A_A_414700"> <perioddate>2010-12-31</perioddate>
>>> <reporttype code=3D"A">As reported</reporttype> </period>=20
>>> </perioddata> <financialdata> <financialgroup=20
>>> financiallegendcode=3D"29.00" legend=3D"Total Assets"> <financial=20
>>> periodref=3D"154_2011-12-31_A_A_414785">1007827</financial>
>>> <financial periodref=3D"154_2010-12-31_A_R_414804">1102209</financial>
>>> <financial periodref=3D"154_2009-12-31_A_A_414700">209987</financial>
>>> </financialgroup>
>>> <financialgroup financiallegendcode=3D"73.00" legend=3D"Pre-Tax Income"=
>=20
>>> <financial periodref=3D"154_2011-12-31_A_A_414785">231673</financial>
>>> <financial periodref=3D"154_2009-12-31_A_A_414700">191115</financial>
>>> </financialgroup>
>>> <financialgroup financiallegendcode=3D"82.00" legend=3D"Net Income">=20
>>> <financial periodref=3D"154_2010-12-31_A_R_414804">28999</financial>
>>> <financial periodref=3D"154_2009-12-31_A_A_414700">191203</financial>
>>> </financialgroup>
>>> <financialgroup financiallegendcode=3D"60.00" legend=3D"Revenue -=20
>>> Operating/Total"> <financial=20
>>> periodref=3D"154_2011-12-31_A_A_414785">573949</financial>
>>> <financial periodref=3D"154_2010-12-31_A_R_414804">529765</financial>
>>> <financial periodref=3D"154_2009-12-31_A_A_414700">447635</financial>
>>> </financialgroup>
>>> </financialdata>
>>> </financials>
>>> </company>
>>> <company>
>>> <fpid>11</fpid>
>>> <legal>Barrick Gold</legal>
>>> <financials>
>>> <perioddata>
>>> <period id=3D"11_2011-12-31_A_A_1">
>>> <perioddate>2011-12-31</perioddate>
>>> <reporttype code=3D"A">As reported</reporttype> </period> <period=20
>>> id=3D"11_2010-12-31_A_A_2"> <perioddate>2010-12-31</perioddate>
>>> <reporttype code=3D"A">As reported</reporttype> </period>=20
>>> </perioddata> <financialdata> <financialgroup=20
>>> financiallegendcode=3D"29.00" legend=3D"Total Assets"> <financial=20
>>> periodref=3D"11_2011-12-31_A_A_1">1007827</financial>
>>> <financial periodref=3D"11_2010-12-31_A_A_2">1102209</financial>
>>> </financialgroup>
>>> <financialgroup financiallegendcode=3D"82.00" legend=3D"Net Income">=20
>>> <financial periodref=3D"11_2010-12-31_A_A_2">191203</financial>
>>> </financialgroup>
>>> <financialgroup financiallegendcode=3D"60.00" legend=3D"Revenue -=20
>>> Operating/Total"> <financial=20
>>> periodref=3D"11_2011-12-31_A_A_1">573949</financial>
>>> </financialgroup>
>>> </financialdata>
>>> </financials>
>>> </company>
>>> </requesteddata>
>>>
>>>
>>> XSL file:
>>>
>>> <?xml version=3D"1.0" encoding=3D"windows-1252"?> <xsl:stylesheet=20
>>> xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform";
>>> version=3D"2.0">
>>> <xsl:output method=3D"html" indent=3D"yes" encoding=3D"windows-1252"/>=
=20
>>> <xsl:key name=3D"legend" match=3D"longname" use=3D"../code"/>
>>>
>>> <xsl:template match=3D"requesteddata"> <xsl:for-each select=3D"company"=
>=20
>>> <table border=3D"1"> <tr> <td colspan=3D"4"> <xsl:value-of=20
>>> select=3D"legal"/> </td> </tr> <xsl:apply-templates=20
>>> select=3D"financials/perioddata"/> <xsl:apply-templates=20
>>> select=3D"financials/financialdata/financialgroup[key('legend',
>>> @financiallegendcode)]"/>
>>> </table>
>>> </xsl:for-each>
>>> </xsl:template>
>>>
>>> <xsl:template match=3D"perioddata">
>>> <tr>
>>> <td>&#160;</td>
>>> <xsl:for-each select=3D"period">
>>> <td>
>>> <xsl:value-of select=3D"perioddate"/><xsl:text> =A0-=20
>>> </xsl:text><xsl:value-of select=3D"reporttype"/> </td> </xsl:for-each>=
=20
>>> </tr> </xsl:template>
>>>
>>> <xsl:template match=3D"financials/financialdata/financialgroup">
>>> <tr>
>>> <td><xsl:value-of select=3D"key('legend',=20
>>> @financiallegendcode)"/></td> <xsl:for-each select=3D"financial">=20
>>> <td><xsl:value-of select=3D"."/></td> </xsl:for-each> </tr>=20
>>> </xsl:template>
>>>
>>> <xsl:template name=3D"presentation"/>
>>> </xsl:stylesheet>
>>>
>>> Output HTML example:
>>>
>>> <table border=3D"1">
>>> <tr>
>>> <td colspan=3D"4">High River Gold Mines Ltd.</td> </tr> <tr>
>>> <td>&#160;</td><td>2011-12-31 - As Reported</td><td>2010-12-31 -
>>> Restated</td><td>2009-12-31 - As Reported</td> </tr> <tr>=20
>>> <td>Revenue -=20
>>> Operating/Total</td><td>573949</td><td>529765</td><td>447635</td>
>>> </tr>
>>> <tr>
>>> <td>Total Assets</td><td>1007827</td><td>1102209</td><td>209987</td>
>>> </tr>
>>> <tr>
>>> <td>Pre-Tax Income</td><td>231673</td><td>&#160;</td><td>191115</td>
>>> </tr>
>>> <tr>
>>> <td>Made-up filler</td><td>&#160;</td><td>&#160;</td><td>&#160;</td>
>>> </tr>
>>> <tr>
>>> <td>Net Income</td><td>&#160;</td><td>28999</td><td>191203</td>
>>> </tr>
>>> </table>
>>>
>>> <table border=3D"1">
>>> <tr>
>>> <td colspan=3D"4">Barrick Gold</td>
>>> </tr>
>>> <tr>
>>> <td>&#160;</td><td>2011-12-31 - As Reported</td><td>2010-12-31 - As=20
>>> Reported</td> </tr> <tr> <td>Revenue -=20
>>> Operating/Total</td><td>573949</td><td>&#160;</td>
>>> </tr>
>>> <tr>
>>> <td>Total Assets</td><td>1007827</td><td>1102209</td>
>>> </tr>
>>> <tr>
>>> <td>Pre-Tax Income</td><td>&#160;</td><td>&#160;</td>
>>> </tr>
>>> <tr>
>>> <td>Made-up filler</td><td>&#160;</td><td>&#160;</td>
>>> </tr>
>>> <tr>
>>> <td>Net Income</td><td>&#160;</td><td>191203</td>
>>> </tr>
>>> </table>
>
>
> --
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> Wendell Piez =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mailt=
o:wapiez@mulberrytech.com=20
> Mulberry Technologies, Inc. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://www.mul=
berrytech.com
> 17 West Jefferson Street =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Direct Ph=
one: 301/315-9635=20
> Suite 207 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0Phone: 301/315-9631=20
> Rockville, MD =A020850 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 Fax: 301/315-8285
> ----------------------------------------------------------------------
> =A0Mulberry Technologies: A Consultancy Specializing in SGML and XML=20
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> --~------------------------------------------------------------------
> XSL-List info and archive: =A0http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
> --~--
>

--~------------------------------------------------------------------
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@lists.mulberrytech.com>
--~--

------------------------------

Date: Mon, 11 Jun 2012 17:11:41 +0100
To: xsl-list@lists.mulberrytech.com
From: Ihe Onwuka <ihe.onwuka@googlemail.com>
Subject: Re: [xsl] Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)
Message-ID: <CALfs7+wRJt4ueL-KDAoBHeuYonz53yRNR9R0xL-wPbP44SQspA@mail.gmail.com>

When you want to process the same node in more than one way.

eg to produce the body of a book, the index and the table of contents,
you are processing the same nodes but doing different things with
them.

On Mon, Jun 11, 2012 at 5:01 PM, Michele R Combs <mrrothen@syr.edu> wrote:
> I notice that you're using "mode" in this solution. =A0Can someone point =
me to a good explanation of modes, with good examples? =A0I haven't worked =
much with them and am finding them a bit confusing.
>
> Thanks
>
> Michele
>
> On Wed, Jun 6, 2012 at 6:04 PM, Wendell Piez <wapiez@mulberrytech.com> wr=
ote:
>> Daniel,
>>
>>
>> On 6/6/2012 3:31 PM, daniel whitney wrote:
>>>
>>> OK so I came up with a solution for Part 2 of my question. Not sure
>>> if it's the ideal, but it works:
>>>
>>> Would Part 1 have a similar solution? Would I store the "lookup"
>>> portion in a global variable and just call that again and again?
>>
>>
>> Basically, yes, although you will get closer to your ideal of clarity,
>> grace and maintainability if you refactor with templates. When doing
>> so, you can pass parameters to retain context.
>>
>> So something like:
>>
>> <xsl:template match=3D"financialgroup">
>>
>> =A0<tr>
>> =A0 =A0<td>
>> =A0 =A0 =A0<xsl:value-of select=3D"key('legend', @financiallegendcode)"/=
>
>> =A0 =A0</td>
>> =A0 =A0<xsl:apply-templates select=3D"ancestor::financials/perioddate/pe=
riod"
>> =A0 =A0 =A0mode=3D"period-cell">
>> =A0 =A0 =A0<xsl:with-param name=3D"fgroup" select=3D"."/>
>> =A0 =A0</xsl:apply-templates>
>> =A0</tr>
>> </xsl:template>
>>
>> ... and to receive the call:
>>
>> <xsl:template match=3D"period" mode=3D"period-cell">
>> =A0<xsl:param name=3D"fgroup" as=3D"element(financialgroup)"/>
>>
>> =A0<xsl:variable name=3D"idBase" select=3D"@id"/>
>> =A0<td>
>> =A0 =A0<xsl:value-of
>> =A0 =A0 =A0select=3D"($fgroup/financial[@periodref=3D$idBase],'....')[1]=
"/>
>> =A0</td>
>> </xsl:template>
>>
>> Obviously the details aren't worked out here, and note also I'm using
>> an XPath 2.0 idiom to provide the fallback value when the particular
>> 'financialgroup' element has no 'financial' value for the period.
>>
>> This also fixes a bug in your code where every period covered is
>> assigned all values for all of them (or the first of them, if run as XSL=
T 1.0).
>>
>> I hope this helps,
>> Wendell
>>
>>
>>> <xsl:template match=3D"financialgroup"> <xsl:variable
>>> name=3D"currentFinancial" select=3D"financial"/> <tr> <td><xsl:value-of
>>> select=3D"key('legend', @financiallegendcode)"/></td> <xsl:for-each
>>> select=3D"ancestor::financials/perioddata/period">
>>> <xsl:variable name=3D"idBase" select=3D"@id"/> <td align=3D"right">
>>> <xsl:choose> <xsl:when test=3D"$currentFinancial/@periodref=3D$idBase">
>>> <xsl:value-of select=3D"$currentFinancial[@periodref=3D$idBase]"/>
>>> </xsl:when>
>>> <xsl:otherwise>
>>> <xsl:text>....</xsl:text>
>>> </xsl:otherwise>
>>> </xsl:choose>
>>> </td>
>>> </xsl:for-each>
>>> </tr>
>>> </xsl:template>
>>>
>>>
>>> On Wed, Jun 6, 2012 at 10:41 AM, daniel
>>> whitney<dbf.whitney@gmail.com>
>>> =A0wrote:
>>>>
>>>> Hi I'm having problems trying to figure out how to accomplish this
>>>> and what the best strategy might be.
>>>>
>>>> It's a 2 part problem. The first with keys. The second with ID/IDREF.
>>>>
>>>> 1. I have an xml file with a "lookup" table at the top
>>>> (presentation/financiallegend). I want to output, as html, the
>>>> "longname" element in a table cell whether it exists in the "data"
>>>> or not. If it does exist in the data then the following =A0cells will
>>>> contain the financial data. If it doesn't exist, the following cells
>>>> would just be empty. My XSL file outputs the rows with financial
>>>> data correctly, but does not include rows where only the "longname"
>>>> exists (no financial data).
>>>>
>>>> 2. The header row of the table is a row of dates, each with a unique
>>>> id. The subequent rows are financial data that have to align with
>>>> the corresponding date id. The financial data include refs to their
>>>> corresponding date ids, but of course there might be ids without a
>>>> corresponding idref. So I have no idea how get the columns to align
>>>> correctly.
>>>>
>>>> This is a very basic example. The file itself has dozens of lookup
>>>> tables (not too many IDs). So I'm wondering how to accomplisth this
>>>> and what is the best strategy to keep things as clean and simple as
>>>> possible.
>>>>
>>>> Does having a schema contribute to the simplicity of the XSL
>>>> somehow, in regards to keys? Or are they essentially separate entities=
?
>>>>
>>>> Any help is, of course, greatly appreciated.
>>>>
>>>> Thanks,
>>>>
>>>> Dan
>>>>
>>>> XML file:
>>>>
>>>> <?xml version=3D"1.0" encoding=3D"windows-1252"?> <requesteddata>
>>>> <presentation> <financiallegend> <code>60.00</code>
>>>> <longname>Revenue - Operating/Total</longname> </financiallegend>
>>>> <financiallegend> <code>29.00</code> <longname>Total
>>>> Assets</longname> </financiallegend> <financiallegend>
>>>> <code>73.00</code> <longname>Pre-Tax Income</longname>
>>>> </financiallegend> <financiallegend> <code>2.00</code>
>>>> <longname>Made-up filler</longname> </financiallegend>
>>>> <financiallegend> <code>82.00</code> <longname>Net Income</longname>
>>>> </financiallegend> </presentation> <company> <fpid>154</fpid>
>>>> <legal>High River Gold Mines Ltd.</legal> <financials> <perioddata>
>>>> <period id=3D"154_2011-12-31_A_A_414785">
>>>> <perioddate>2011-12-31</perioddate>
>>>> <reporttype code=3D"A">As reported</reporttype> </period> <period
>>>> id=3D"154_2010-12-31_A_R_414804"> <perioddate>2010-12-31</perioddate>
>>>> <reporttype code=3D"R">Restated</reporttype> </period> <period
>>>> id=3D"154_2009-12-31_A_A_414700"> <perioddate>2010-12-31</perioddate>
>>>> <reporttype code=3D"A">As reported</reporttype> </period>
>>>> </perioddata> <financialdata> <financialgroup
>>>> financiallegendcode=3D"29.00" legend=3D"Total Assets"> <financial
>>>> periodref=3D"154_2011-12-31_A_A_414785">1007827</financial>
>>>> <financial periodref=3D"154_2010-12-31_A_R_414804">1102209</financial>
>>>> <financial periodref=3D"154_2009-12-31_A_A_414700">209987</financial>
>>>> </financialgroup>
>>>> <financialgroup financiallegendcode=3D"73.00" legend=3D"Pre-Tax Income=
">
>>>> <financial periodref=3D"154_2011-12-31_A_A_414785">231673</financial>
>>>> <financial periodref=3D"154_2009-12-31_A_A_414700">191115</financial>
>>>> </financialgroup>
>>>> <financialgroup financiallegendcode=3D"82.00" legend=3D"Net Income">
>>>> <financial periodref=3D"154_2010-12-31_A_R_414804">28999</financial>
>>>> <financial periodref=3D"154_2009-12-31_A_A_414700">191203</financial>
>>>> </financialgroup>
>>>> <financialgroup financiallegendcode=3D"60.00" legend=3D"Revenue -
>>>> Operating/Total"> <financial
>>>> periodref=3D"154_2011-12-31_A_A_414785">573949</financial>
>>>> <financial periodref=3D"154_2010-12-31_A_R_414804">529765</financial>
>>>> <financial periodref=3D"154_2009-12-31_A_A_414700">447635</financial>
>>>> </financialgroup>
>>>> </financialdata>
>>>> </financials>
>>>> </company>
>>>> <company>
>>>> <fpid>11</fpid>
>>>> <legal>Barrick Gold</legal>
>>>> <financials>
>>>> <perioddata>
>>>> <period id=3D"11_2011-12-31_A_A_1">
>>>> <perioddate>2011-12-31</perioddate>
>>>> <reporttype code=3D"A">As reported</reporttype> </period> <period
>>>> id=3D"11_2010-12-31_A_A_2"> <perioddate>2010-12-31</perioddate>
>>>> <reporttype code=3D"A">As reported</reporttype> </period>
>>>> </perioddata> <financialdata> <financialgroup
>>>> financiallegendcode=3D"29.00" legend=3D"Total Assets"> <financial
>>>> periodref=3D"11_2011-12-31_A_A_1">1007827</financial>
>>>> <financial periodref=3D"11_2010-12-31_A_A_2">1102209</financial>
>>>> </financialgroup>
>>>> <financialgroup financiallegendcode=3D"82.00" legend=3D"Net Income">
>>>> <financial periodref=3D"11_2010-12-31_A_A_2">191203</financial>
>>>> </financialgroup>
>>>> <financialgroup financiallegendcode=3D"60.00" legend=3D"Revenue -
>>>> Operating/Total"> <financial
>>>> periodref=3D"11_2011-12-31_A_A_1">573949</financial>
>>>> </financialgroup>
>>>> </financialdata>
>>>> </financials>
>>>> </company>
>>>> </requesteddata>
>>>>
>>>>
>>>> XSL file:
>>>>
>>>> <?xml version=3D"1.0" encoding=3D"windows-1252"?> <xsl:stylesheet
>>>> xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform";
>>>> version=3D"2.0">
>>>> <xsl:output method=3D"html" indent=3D"yes" encoding=3D"windows-1252"/>
>>>> <xsl:key name=3D"legend" match=3D"longname" use=3D"../code"/>
>>>>
>>>> <xsl:template match=3D"requesteddata"> <xsl:for-each select=3D"company=
">
>>>> <table border=3D"1"> <tr> <td colspan=3D"4"> <xsl:value-of
>>>> select=3D"legal"/> </td> </tr> <xsl:apply-templates
>>>> select=3D"financials/perioddata"/> <xsl:apply-templates
>>>> select=3D"financials/financialdata/financialgroup[key('legend',
>>>> @financiallegendcode)]"/>
>>>> </table>
>>>> </xsl:for-each>
>>>> </xsl:template>
>>>>
>>>> <xsl:template match=3D"perioddata">
>>>> <tr>
>>>> <td>&#160;</td>
>>>> <xsl:for-each select=3D"period">
>>>> <td>
>>>> <xsl:value-of select=3D"perioddate"/><xsl:text> =A0-
>>>> </xsl:text><xsl:value-of select=3D"reporttype"/> </td> </xsl:for-each>
>>>> </tr> </xsl:template>
>>>>
>>>> <xsl:template match=3D"financials/financialdata/financialgroup">
>>>> <tr>
>>>> <td><xsl:value-of select=3D"key('legend',
>>>> @financiallegendcode)"/></td> <xsl:for-each select=3D"financial">
>>>> <td><xsl:value-of select=3D"."/></td> </xsl:for-each> </tr>
>>>> </xsl:template>
>>>>
>>>> <xsl:template name=3D"presentation"/>
>>>> </xsl:stylesheet>
>>>>
>>>> Output HTML example:
>>>>
>>>> <table border=3D"1">
>>>> <tr>
>>>> <td colspan=3D"4">High River Gold Mines Ltd.</td> </tr> <tr>
>>>> <td>&#160;</td><td>2011-12-31 - As Reported</td><td>2010-12-31 -
>>>> Restated</td><td>2009-12-31 - As Reported</td> </tr> <tr>
>>>> <td>Revenue -
>>>> Operating/Total</td><td>573949</td><td>529765</td><td>447635</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Total Assets</td><td>1007827</td><td>1102209</td><td>209987</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Pre-Tax Income</td><td>231673</td><td>&#160;</td><td>191115</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Made-up filler</td><td>&#160;</td><td>&#160;</td><td>&#160;</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Net Income</td><td>&#160;</td><td>28999</td><td>191203</td>
>>>> </tr>
>>>> </table>
>>>>
>>>> <table border=3D"1">
>>>> <tr>
>>>> <td colspan=3D"4">Barrick Gold</td>
>>>> </tr>
>>>> <tr>
>>>> <td>&#160;</td><td>2011-12-31 - As Reported</td><td>2010-12-31 - As
>>>> Reported</td> </tr> <tr> <td>Revenue -
>>>> Operating/Total</td><td>573949</td><td>&#160;</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Total Assets</td><td>1007827</td><td>1102209</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Pre-Tax Income</td><td>&#160;</td><td>&#160;</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Made-up filler</td><td>&#160;</td><td>&#160;</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Net Income</td><td>&#160;</td><td>191203</td>
>>>> </tr>
>>>> </table>
>>
>>
>> --
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> Wendell Piez =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mail=
to:wapiez@mulberrytech.com
>> Mulberry Technologies, Inc. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://www.mu=
lberrytech.com
>> 17 West Jefferson Street =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Direct P=
hone: 301/315-9635
>> Suite 207 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0Phone: 301/315-9631
>> Rockville, MD =A020850 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 Fax: 301/315-8285
>> ----------------------------------------------------------------------
>> =A0Mulberry Technologies: A Consultancy Specializing in SGML and XML
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>>
>> --~------------------------------------------------------------------
>> XSL-List info and archive: =A0http://www.mulberrytech.com/xsl/xsl-list
>> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
>> or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
>> --~--
>>
>
> --~------------------------------------------------------------------
> XSL-List info and archive: =A0http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
> --~--
>
>
> --~------------------------------------------------------------------
> XSL-List info and archive: =A0http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
> --~--
>

------------------------------

Date: Mon, 11 Jun 2012 16:54:00 +0000
To: "'xsl-list@lists.mulberrytech.com'" <xsl-list@lists.mulberrytech.com>
From: Michele R Combs <mrrothen@syr.edu>
Subject: RE: [xsl] Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)
Message-ID: <2FD713CF35B5A748AD77C21ECEF69AAA15BFBD@SUEX10-mbx-05.ad.syr.edu>

Thanks.  I should have been clearer in my request.  I understand the concep=
t of modes (what they are for) but have been having difficulty putting them=
 into execution, and/or untangling them in pre-existing code.  A technical =
explanation with examples is more what I'm looking for.

Michele

-----Original Message-----
From: Ihe Onwuka [mailto:ihe.onwuka@googlemail.com]=20
Sent: Monday, June 11, 2012 12:12 PM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)

When you want to process the same node in more than one way.

eg to produce the body of a book, the index and the table of contents, you =
are processing the same nodes but doing different things with them.

On Mon, Jun 11, 2012 at 5:01 PM, Michele R Combs <mrrothen@syr.edu> wrote:
> I notice that you're using "mode" in this solution. =A0Can someone point =
me to a good explanation of modes, with good examples? =A0I haven't worked =
much with them and am finding them a bit confusing.
>
> Thanks
>
> Michele
>
> On Wed, Jun 6, 2012 at 6:04 PM, Wendell Piez <wapiez@mulberrytech.com> wr=
ote:
>> Daniel,
>>
>>
>> On 6/6/2012 3:31 PM, daniel whitney wrote:
>>>
>>> OK so I came up with a solution for Part 2 of my question. Not sure=20
>>> if it's the ideal, but it works:
>>>
>>> Would Part 1 have a similar solution? Would I store the "lookup"
>>> portion in a global variable and just call that again and again?
>>
>>
>> Basically, yes, although you will get closer to your ideal of=20
>> clarity, grace and maintainability if you refactor with templates.=20
>> When doing so, you can pass parameters to retain context.
>>
>> So something like:
>>
>> <xsl:template match=3D"financialgroup">
>>
>> =A0<tr>
>> =A0 =A0<td>
>> =A0 =A0 =A0<xsl:value-of select=3D"key('legend', @financiallegendcode)"/=
>
>> =A0 =A0</td>
>> =A0 =A0<xsl:apply-templates select=3D"ancestor::financials/perioddate/pe=
riod"
>> =A0 =A0 =A0mode=3D"period-cell">
>> =A0 =A0 =A0<xsl:with-param name=3D"fgroup" select=3D"."/>
>> =A0 =A0</xsl:apply-templates>
>> =A0</tr>
>> </xsl:template>
>>
>> ... and to receive the call:
>>
>> <xsl:template match=3D"period" mode=3D"period-cell">
>> =A0<xsl:param name=3D"fgroup" as=3D"element(financialgroup)"/>
>>
>> =A0<xsl:variable name=3D"idBase" select=3D"@id"/>
>> =A0<td>
>> =A0 =A0<xsl:value-of
>> =A0 =A0 =A0select=3D"($fgroup/financial[@periodref=3D$idBase],'....')[1]=
"/>
>> =A0</td>
>> </xsl:template>
>>
>> Obviously the details aren't worked out here, and note also I'm using=20
>> an XPath 2.0 idiom to provide the fallback value when the particular=20
>> 'financialgroup' element has no 'financial' value for the period.
>>
>> This also fixes a bug in your code where every period covered is=20
>> assigned all values for all of them (or the first of them, if run as XSL=
T 1.0).
>>
>> I hope this helps,
>> Wendell
>>
>>
>>> <xsl:template match=3D"financialgroup"> <xsl:variable=20
>>> name=3D"currentFinancial" select=3D"financial"/> <tr> <td><xsl:value-of=
=20
>>> select=3D"key('legend', @financiallegendcode)"/></td> <xsl:for-each=20
>>> select=3D"ancestor::financials/perioddata/period">
>>> <xsl:variable name=3D"idBase" select=3D"@id"/> <td align=3D"right">=20
>>> <xsl:choose> <xsl:when test=3D"$currentFinancial/@periodref=3D$idBase">
>>> <xsl:value-of select=3D"$currentFinancial[@periodref=3D$idBase]"/>
>>> </xsl:when>
>>> <xsl:otherwise>
>>> <xsl:text>....</xsl:text>
>>> </xsl:otherwise>
>>> </xsl:choose>
>>> </td>
>>> </xsl:for-each>
>>> </tr>
>>> </xsl:template>
>>>
>>>
>>> On Wed, Jun 6, 2012 at 10:41 AM, daniel=20
>>> whitney<dbf.whitney@gmail.com>
>>> =A0wrote:
>>>>
>>>> Hi I'm having problems trying to figure out how to accomplish this=20
>>>> and what the best strategy might be.
>>>>
>>>> It's a 2 part problem. The first with keys. The second with ID/IDREF.
>>>>
>>>> 1. I have an xml file with a "lookup" table at the top=20
>>>> (presentation/financiallegend). I want to output, as html, the=20
>>>> "longname" element in a table cell whether it exists in the "data"
>>>> or not. If it does exist in the data then the following =A0cells will=
=20
>>>> contain the financial data. If it doesn't exist, the following=20
>>>> cells would just be empty. My XSL file outputs the rows with=20
>>>> financial data correctly, but does not include rows where only the "lo=
ngname"
>>>> exists (no financial data).
>>>>
>>>> 2. The header row of the table is a row of dates, each with a=20
>>>> unique id. The subequent rows are financial data that have to align=20
>>>> with the corresponding date id. The financial data include refs to=20
>>>> their corresponding date ids, but of course there might be ids=20
>>>> without a corresponding idref. So I have no idea how get the=20
>>>> columns to align correctly.
>>>>
>>>> This is a very basic example. The file itself has dozens of lookup=20
>>>> tables (not too many IDs). So I'm wondering how to accomplisth this=20
>>>> and what is the best strategy to keep things as clean and simple as=20
>>>> possible.
>>>>
>>>> Does having a schema contribute to the simplicity of the XSL=20
>>>> somehow, in regards to keys? Or are they essentially separate entities=
?
>>>>
>>>> Any help is, of course, greatly appreciated.
>>>>
>>>> Thanks,
>>>>
>>>> Dan
>>>>
>>>> XML file:
>>>>
>>>> <?xml version=3D"1.0" encoding=3D"windows-1252"?> <requesteddata>=20
>>>> <presentation> <financiallegend> <code>60.00</code>=20
>>>> <longname>Revenue - Operating/Total</longname> </financiallegend>=20
>>>> <financiallegend> <code>29.00</code> <longname>Total=20
>>>> Assets</longname> </financiallegend> <financiallegend>=20
>>>> <code>73.00</code> <longname>Pre-Tax Income</longname>=20
>>>> </financiallegend> <financiallegend> <code>2.00</code>=20
>>>> <longname>Made-up filler</longname> </financiallegend>=20
>>>> <financiallegend> <code>82.00</code> <longname>Net=20
>>>> Income</longname> </financiallegend> </presentation> <company>=20
>>>> <fpid>154</fpid> <legal>High River Gold Mines Ltd.</legal>=20
>>>> <financials> <perioddata> <period id=3D"154_2011-12-31_A_A_414785">=20
>>>> <perioddate>2011-12-31</perioddate>
>>>> <reporttype code=3D"A">As reported</reporttype> </period> <period=20
>>>> id=3D"154_2010-12-31_A_R_414804"> <perioddate>2010-12-31</perioddate>
>>>> <reporttype code=3D"R">Restated</reporttype> </period> <period=20
>>>> id=3D"154_2009-12-31_A_A_414700"> <perioddate>2010-12-31</perioddate>
>>>> <reporttype code=3D"A">As reported</reporttype> </period>=20
>>>> </perioddata> <financialdata> <financialgroup=20
>>>> financiallegendcode=3D"29.00" legend=3D"Total Assets"> <financial=20
>>>> periodref=3D"154_2011-12-31_A_A_414785">1007827</financial>
>>>> <financial=20
>>>> periodref=3D"154_2010-12-31_A_R_414804">1102209</financial>
>>>> <financial periodref=3D"154_2009-12-31_A_A_414700">209987</financial>
>>>> </financialgroup>
>>>> <financialgroup financiallegendcode=3D"73.00" legend=3D"Pre-Tax=20
>>>> Income"> <financial=20
>>>> periodref=3D"154_2011-12-31_A_A_414785">231673</financial>
>>>> <financial periodref=3D"154_2009-12-31_A_A_414700">191115</financial>
>>>> </financialgroup>
>>>> <financialgroup financiallegendcode=3D"82.00" legend=3D"Net Income">=20
>>>> <financial periodref=3D"154_2010-12-31_A_R_414804">28999</financial>
>>>> <financial periodref=3D"154_2009-12-31_A_A_414700">191203</financial>
>>>> </financialgroup>
>>>> <financialgroup financiallegendcode=3D"60.00" legend=3D"Revenue -=20
>>>> Operating/Total"> <financial=20
>>>> periodref=3D"154_2011-12-31_A_A_414785">573949</financial>
>>>> <financial periodref=3D"154_2010-12-31_A_R_414804">529765</financial>
>>>> <financial periodref=3D"154_2009-12-31_A_A_414700">447635</financial>
>>>> </financialgroup>
>>>> </financialdata>
>>>> </financials>
>>>> </company>
>>>> <company>
>>>> <fpid>11</fpid>
>>>> <legal>Barrick Gold</legal>
>>>> <financials>
>>>> <perioddata>
>>>> <period id=3D"11_2011-12-31_A_A_1">
>>>> <perioddate>2011-12-31</perioddate>
>>>> <reporttype code=3D"A">As reported</reporttype> </period> <period=20
>>>> id=3D"11_2010-12-31_A_A_2"> <perioddate>2010-12-31</perioddate>
>>>> <reporttype code=3D"A">As reported</reporttype> </period>=20
>>>> </perioddata> <financialdata> <financialgroup=20
>>>> financiallegendcode=3D"29.00" legend=3D"Total Assets"> <financial=20
>>>> periodref=3D"11_2011-12-31_A_A_1">1007827</financial>
>>>> <financial periodref=3D"11_2010-12-31_A_A_2">1102209</financial>
>>>> </financialgroup>
>>>> <financialgroup financiallegendcode=3D"82.00" legend=3D"Net Income">=20
>>>> <financial periodref=3D"11_2010-12-31_A_A_2">191203</financial>
>>>> </financialgroup>
>>>> <financialgroup financiallegendcode=3D"60.00" legend=3D"Revenue -=20
>>>> Operating/Total"> <financial=20
>>>> periodref=3D"11_2011-12-31_A_A_1">573949</financial>
>>>> </financialgroup>
>>>> </financialdata>
>>>> </financials>
>>>> </company>
>>>> </requesteddata>
>>>>
>>>>
>>>> XSL file:
>>>>
>>>> <?xml version=3D"1.0" encoding=3D"windows-1252"?> <xsl:stylesheet=20
>>>> xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform";
>>>> version=3D"2.0">
>>>> <xsl:output method=3D"html" indent=3D"yes" encoding=3D"windows-1252"/>=
=20
>>>> <xsl:key name=3D"legend" match=3D"longname" use=3D"../code"/>
>>>>
>>>> <xsl:template match=3D"requesteddata"> <xsl:for-each=20
>>>> select=3D"company"> <table border=3D"1"> <tr> <td colspan=3D"4">=20
>>>> <xsl:value-of select=3D"legal"/> </td> </tr> <xsl:apply-templates=20
>>>> select=3D"financials/perioddata"/> <xsl:apply-templates=20
>>>> select=3D"financials/financialdata/financialgroup[key('legend',
>>>> @financiallegendcode)]"/>
>>>> </table>
>>>> </xsl:for-each>
>>>> </xsl:template>
>>>>
>>>> <xsl:template match=3D"perioddata">
>>>> <tr>
>>>> <td>&#160;</td>
>>>> <xsl:for-each select=3D"period">
>>>> <td>
>>>> <xsl:value-of select=3D"perioddate"/><xsl:text> =A0-=20
>>>> </xsl:text><xsl:value-of select=3D"reporttype"/> </td>=20
>>>> </xsl:for-each> </tr> </xsl:template>
>>>>
>>>> <xsl:template match=3D"financials/financialdata/financialgroup">
>>>> <tr>
>>>> <td><xsl:value-of select=3D"key('legend',=20
>>>> @financiallegendcode)"/></td> <xsl:for-each select=3D"financial">=20
>>>> <td><xsl:value-of select=3D"."/></td> </xsl:for-each> </tr>=20
>>>> </xsl:template>
>>>>
>>>> <xsl:template name=3D"presentation"/> </xsl:stylesheet>
>>>>
>>>> Output HTML example:
>>>>
>>>> <table border=3D"1">
>>>> <tr>
>>>> <td colspan=3D"4">High River Gold Mines Ltd.</td> </tr> <tr>
>>>> <td>&#160;</td><td>2011-12-31 - As Reported</td><td>2010-12-31 -
>>>> Restated</td><td>2009-12-31 - As Reported</td> </tr> <tr>=20
>>>> <td>Revenue -=20
>>>> Operating/Total</td><td>573949</td><td>529765</td><td>447635</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Total=20
>>>> Assets</td><td>1007827</td><td>1102209</td><td>209987</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Pre-Tax=20
>>>> Income</td><td>231673</td><td>&#160;</td><td>191115</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Made-up=20
>>>> filler</td><td>&#160;</td><td>&#160;</td><td>&#160;</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Net Income</td><td>&#160;</td><td>28999</td><td>191203</td>
>>>> </tr>
>>>> </table>
>>>>
>>>> <table border=3D"1">
>>>> <tr>
>>>> <td colspan=3D"4">Barrick Gold</td>
>>>> </tr>
>>>> <tr>
>>>> <td>&#160;</td><td>2011-12-31 - As Reported</td><td>2010-12-31 - As=20
>>>> Reported</td> </tr> <tr> <td>Revenue -=20
>>>> Operating/Total</td><td>573949</td><td>&#160;</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Total Assets</td><td>1007827</td><td>1102209</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Pre-Tax Income</td><td>&#160;</td><td>&#160;</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Made-up filler</td><td>&#160;</td><td>&#160;</td>
>>>> </tr>
>>>> <tr>
>>>> <td>Net Income</td><td>&#160;</td><td>191203</td>
>>>> </tr>
>>>> </table>
>>
>>
>> --
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> =3D Wendell Piez =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
>> mailto:wapiez@mulberrytech.com Mulberry Technologies, Inc. =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0
>> http://www.mulberrytech.com
>> 17 West Jefferson Street =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Direct P=
hone:=20
>> 301/315-9635 Suite 207 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
>> Phone: 301/315-9631 Rockville, MD =A020850 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=20
>> Fax: 301/315-8285
>> ---------------------------------------------------------------------
>> -
>> =A0Mulberry Technologies: A Consultancy Specializing in SGML and XML=20
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> =3D
>>
>> --~------------------------------------------------------------------
>> XSL-List info and archive: =A0http://www.mulberrytech.com/xsl/xsl-list
>> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
>> or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
>> --~--
>>
>
> --~------------------------------------------------------------------
> XSL-List info and archive: =A0http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
> --~--
>
>
> --~------------------------------------------------------------------
> XSL-List info and archive: =A0http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@lists.mulberrytech.com>
> --~--
>

--~------------------------------------------------------------------
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@lists.mulberrytech.com>
--~--

------------------------------

Date: Mon, 11 Jun 2012 13:19:20 -0400
To: xsl-list@lists.mulberrytech.com
From: Wendell Piez <wapiez@mulberrytech.com>
Subject: Re: [xsl] Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)
Message-ID: <4FD62898.3010506@mulberrytech.com>

Michele,

In the example you asked about (the code I mocked up for Daniel), I used
a mode when applying templates to "ancestor::financials/perioddate/
period" not because I absolutely had to (it might have worked as well
without the mode depending on what else was or wasn't happening), but
just to avoid and forestall difficulties in case it was necessary.

I guessed it might be necessary mainly because I was processing the
element for a purpose other than the plain-vanilla ordinary reason,
namely to display its contents. In this case, the 'period' element was
being used only as a kind of scaffolding for generating output for
another element (the one passed in as the $fgroup parameter). Just in
case 'period' elements were also due to be processed in a more normal
way (presumably with a template not assigned to a mode), using a mode
here seemed prudent.

That being said, there isn't any one single thing modes are used for. On
the contrary, many neat solutions to hard problems will use templates --
which have to be put into modes so they do not conflict with other
templates matching the same nodes for other reasons.

So the mode turns up not because we are "using a mode" so much as
because we're "using a template" (or family of templates), and the mode
keeps it or them under control and out of the way.

Cheers,
Wendell

> On Mon, Jun 11, 2012 at 5:01 PM, Michele R Combs<mrrothen@syr.edu>
> wrote:
>> I notice that you're using "mode" in this solution.  Can someone
>> point me to a good explanation of modes, with good examples?  I
>> haven't worked much with them and am finding them a bit confusing.
>>
>> Thanks
>>
>> Michele
>>
>> On Wed, Jun 6, 2012 at 6:04 PM, Wendell
>> Piez<wapiez@mulberrytech.com>  wrote:
>>> Daniel,
>>>
>>>
>>> On 6/6/2012 3:31 PM, daniel whitney wrote:
>>>>
>>>> OK so I came up with a solution for Part 2 of my question. Not
>>>> sure if it's the ideal, but it works:
>>>>
>>>> Would Part 1 have a similar solution? Would I store the
>>>> "lookup" portion in a global variable and just call that again
>>>> and again?
>>>
>>>
>>> Basically, yes, although you will get closer to your ideal of
>>> clarity, grace and maintainability if you refactor with
>>> templates. When doing so, you can pass parameters to retain
>>> context.
>>>
>>> So something like:
>>>
>>> <xsl:template match="financialgroup">
>>>
>>> <tr> <td> <xsl:value-of select="key('legend',
>>> @financiallegendcode)"/> </td> <xsl:apply-templates
>>> select="ancestor::financials/perioddate/period"
>>> mode="period-cell"> <xsl:with-param name="fgroup" select="."/>
>>> </xsl:apply-templates> </tr> </xsl:template>
>>>
>>> ... and to receive the call:
>>>
>>> <xsl:template match="period" mode="period-cell"> <xsl:param
>>> name="fgroup" as="element(financialgroup)"/>
>>>
>>> <xsl:variable name="idBase" select="@id"/> <td> <xsl:value-of
>>> select="($fgroup/financial[@periodref=$idBase],'....')[1]"/>
>>> </td> </xsl:template>
>>>
>>> Obviously the details aren't worked out here, and note also I'm
>>> using an XPath 2.0 idiom to provide the fallback value when the
>>> particular 'financialgroup' element has no 'financial' value for
>>> the period.
>>>
>>> This also fixes a bug in your code where every period covered is
>>>  assigned all values for all of them (or the first of them, if
>>> run as XSLT 1.0).
>>>
>>> I hope this helps, Wendell
>>>
>>>
>>>> <xsl:template match="financialgroup">  <xsl:variable
>>>> name="currentFinancial" select="financial"/>  <tr>
>>>> <td><xsl:value-of select="key('legend',
>>>> @financiallegendcode)"/></td>  <xsl:for-each
>>>> select="ancestor::financials/perioddata/period"> <xsl:variable
>>>> name="idBase" select="@id"/>  <td align="right"> <xsl:choose>
>>>> <xsl:when test="$currentFinancial/@periodref=$idBase">
>>>> <xsl:value-of select="$currentFinancial[@periodref=$idBase]"/>
>>>>  </xsl:when> <xsl:otherwise> <xsl:text>....</xsl:text>
>>>> </xsl:otherwise> </xsl:choose> </td> </xsl:for-each> </tr>
>>>> </xsl:template>

--
======================================================================
Wendell Piez                            mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

------------------------------

Date: Mon, 11 Jun 2012 13:19:44 -0400
To: xsl-list@lists.mulberrytech.com,
 "'xsl-list@lists.mulberrytech.com'" <xsl-list@lists.mulberrytech.com>
From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
Subject: RE: [xsl] Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)
Message-Id: <7.0.1.0.2.20120611131413.024ff408@wheresmymailserver.com>

At 2012-06-11 16:54 +0000, Michele R Combs wrote:
>Thanks.  I should have been clearer in my request.  I understand the
>concept of modes (what they are for) but have been having difficulty
>putting them into execution, and/or untangling them in pre-existing
>code.  A technical explanation with examples is more what I'm looking for.

I can't think of much more to add to Ihe's summary description ...
these are the bullets I talk to in class about what to use when:

===8<---
As a general rule of thumb when deciding how to write a template rule:

- when matching different nodes of different names: no special approach
  - modes, context and priority need not come into play when template
rules have no overlapping match conditions
- when matching the same node for different results: use different modes
  - without modes there would be a template conflict (which may not
get reported)
  - need to distinguish the different results in templates of
different collections that get matched using different modes
- when matching different nodes with the same name: use context and
possibly priority
  - the use of context distinguishes nodes from each other by their
respective ancestors or by respective predicates
  - the use of priority distinguishes templates when the implicit
template priority is not unique
===8<---

As he says, when the very same node (not two nodes with the same
properties) needs to be handled in the push processing style with
different template rules, they need to be in different modes.

And his example of processing one node, say a chapter's title
element, in two different ways, such as in the table of contents and
in the body of the book, using modes ensures that one node is handled
differently when pushing it.

There isn't much more to add for a good example of the need to use modes.

I hope this helps.

. . . . . . . . . Ken

--
Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

------------------------------

Date: Mon, 11 Jun 2012 19:12:04 +0100
To: xsl-list@lists.mulberrytech.com
From: Ihe Onwuka <ihe.onwuka@googlemail.com>
Subject: Re: [xsl] Modes (was RE: [xsl] Re: Keys, IDs lookup tables.)
Message-ID: <CALfs7+yRCvYc3Hadye7Bx3tH+gDf7L0x46eRqxxdNZ+0pxAtAw@mail.gmail.com>

On Mon, Jun 11, 2012 at 5:54 PM, Michele R Combs <mrrothen@syr.edu> wrote:
> Thanks. =A0I should have been clearer in my request. =A0I understand the =
concept of modes (what they are for) but have been having difficulty puttin=
g them into execution, and/or untangling them in pre-existing code. =A0A te=
chnical explanation with examples is more what I'm looking for.
>

I have seen modes used to disambiguate template rules where priorities
would have done the job, so the appearance of modes in pre-existing
code may be gratuitous.

My personal preference is to restrict the usage of modes to the use
case where they are necessary, that way the appearance of modes in
code highlights that the nodes in question are  being processed by
more than one template rule and their absence signals they are not. As
Ken usefully pointed out this assumes push style processing.

I find such disciplines useful, it saves you from having to read the
code to find out the same thing.

------------------------------

Date: Mon, 11 Jun 2012 12:17:09 -0400
To: xsl-list@lists.mulberrytech.com
From: Graydon <graydon@marost.ca>
Subject: Re: [xsl] analyze-string help?
Message-ID: <20120611161709.GA26090@fenja.localdomain>

On Sun, Jun 10, 2012 at 09:43:42PM +0100, Michael Kay scripsit:
> > In my ideal world the syntax would evolve so you could constrain the
> > categories -- "\p{Pd except '-'}", "any character that is some kind
> > of dash except for U+002D "hyphen-minus", for example -- since that
> > would make this even more useful for functions that take regular
> > expressions such as tokenize().
>
> XPath regular expressions allow a subtraction operator within a
> character class:
>
> [\p{Lu}-[IO]]
>
> allows any upper case letter except I or O.

Don't know whether to be embarrassed I missed that or delighted it
exists.

Thanks, Michael!

--
Graydon Saunders        XML tools and processes for information delivery.
graydon@marost.ca

------------------------------

Date: Mon, 11 Jun 2012 11:55:45 -0700
To: "'xsl-list@lists.mulberrytech.com'" <xsl-list@lists.mulberrytech.com>
From: Underwood Michelle <michelle.underwood@doj.state.or.us>
Subject: RE: Trying to use fo:page-number-citation to set the
 initial-page-number of the next page-sequence
Message-ID: <B70CCB710BE77B4E8D63CAD8E074E0301FCB3EFFB5@DOJ-EX07.DOJ.pri>

Ken,

Thank you for your replies.

>Unrelated to your question, for performance reasons on some=20
>processors you might wish to review your use of "//" in the following:

These are part of the generated code in the GUI development environment and=
 I can't change them. This IDE separates the creation into several parts: L=
ayouts, Styleset, Business Object (data model based on xml/schema) and fina=
lly the DDV where the content is all brought together and the other parts a=
pplied to it.

I think the error message is because I 'hard-coded' that choose in there in=
stead of using the GUI interface and the program doesn't like it. Or, it co=
uld be that you can't nest choose statements. I'm not sure which. The choos=
e I posted is inside another choose statement that checks on whether this i=
s duplex or simplex printing because if it is simplex then there is no need=
 to worry about pagination. It is also inside the page-sequence tags. I may=
 try making a variable and putting the choose outside the other and using t=
he variable inside the page-sequence tags to see if this stops the error. M=
aybe I can set an Include_Section Boolean that is manipulated by the DDV do=
cument script and used to set  initPageNbr (set to "auto" or the page numbe=
r reference) and hasBlankPage (Boolean used to determine how to set the for=
ce-page) variables.

>One cannot use the end result of citing a page number as the value=20
>for an initial page number in a page sequence.

My question is, why not as long as the referenced page number is generated =
before the referencing page? Is the value of the initial page number evalua=
ted at transform or render? I am assuming render since page numbers aren't =
known until then. If they are evaluated at transform, how is this put into =
the xml file to indicate it to the renderer and can that be manipulated bet=
ween the two? I have read about two pass processing but I am not sure where=
 that happens and the vendor for the IDE states that they would need to dev=
elop a special handler, for a fee, that I assume does this two pass transfo=
rmation or render.

If it can't be done with page number references, how can this be done? I am=
 currently doing this using a variable that I set in the code of the DDV (d=
ocument created by the GUI) but that requires me to accurately predict in d=
evelopment the number of pages that will be generated at runtime. I want th=
is to be 'automatic' rather than programmatic.

> ... I note this bizarre sequence in your fragment:
>
>><xsl:attribute name=3D"initial-page-number">
>>         <xsl:value-of select=3D"'fo:page-number-citation=20
>> ref-id=3D'TH_BlankPage' xmlns:fo=3D'http://www.w3.org/1999/XSL/Format''"=
/>
>></xsl:attribute>
>

This bizarre sequence is my newby attempt to accomplish the following:

I understand that the xslt processing happens at a different time than the =
xsl:fo processing (transform vs render) but I'm looking for a way to tell t=
he renderer which initial page number to use based on the outcome of the xs=
l:choose so that the renderer either uses "auto" or looks at the page numbe=
r of the referenced fo:block id to determine the starting page number of th=
e next section if there is a blank page inserted between them. Likewise, th=
ere must be a way to change the page force based on the outcome of the tran=
sform such as whether or not there is any content in Section 2.

Here is the Use Case (or requirement statement), setup, and examples:

I need a single output file that contains 2 or 3 sections having a common, =
continuous page numbering where Section 1 must have an initial page number =
of 1, start-on-odd, and, unless the optional Section 2 exists, end-on-even,=
 but if Section 2 exists then Section 1 and 2 must be continuous without bl=
ank pages between them and, in regards to page number and ending page force=
, become one Section, but because they may have slightly different footer c=
ontent they must each have a separate static fo:block for the region-after,=
 and when put together they must end-on-even so that Section 3 physically b=
egins on an separate piece of paper when printed in duplex mode and will en=
d-on-even, even if the logical page numbering says that this is an odd numb=
ered page because the page numbering must logically start with the next pag=
e number that follows the end of Section 1-2 regardless of whether a blank =
page is inserted before it causing there to be a difference between the phy=
sical page number and the logic page number.

I am attempting to dynamically set the starting page numbers so that the "P=
age # of [total]" on each page accurately reflects only those pages which h=
ave content.

Here is what I am doing to attempt this:

Section 1 has an empty block at the end of the flow marked TH_EndFlow.
The alternate simple-page-master (any, blank) for Section 1 has a footer re=
gion named BlankFooter.

Section 2 has an empty block at the end of the flow marked TH_EndFlow2.
The alternate simple-page-master (any, blank) for Section 2 has a footer re=
gion named BlankFooter.

Section 3 has an empty block at the end of the flow marked TH_EndForm.
The alternate simple-page-master (any, blank) for Section 3 has no name for=
 the footer region.

In the page-sequence for each of Sections 1 and 2 static-content: BlankFoot=
er has an fo:block with id =3D TH_BlankPage but these are not mapped to or =
used to hold any content and a single document cannot have both fo:blocks i=
n it because they have the same id.

Section 1 has an initial preset to force-page-count=3Dend-on-even and initi=
al-page-number=3D1.
Section 2 has an initial preset to force-page-count=3Dend-on-even and initi=
al-page-number=3Dauto.
Section 3 has an initial preset to force-page-count=3Dend-on-even and initi=
al-page-number=3Dauto.

I need Section 1 to end-on-even only if Section 2 does not exist so that th=
ere is only one fo:block with the id of TH_BlankPage in the resulting docum=
ent. If Section 2 exists I need to change this attribute to "no-force" or "=
auto", I'm not sure which.

If there is a blank page at the end of Section 1, or the combined Section 1=
-2, I need Section 3 to have the starting page number that is the same as t=
he page number of TH_BlankPage, which is always the preceding page if that =
helps any.

In other words, If Section 2 is included, Sections 1 and 2 flow together wh=
en printed in duplex (both sides of the paper) and insert only one blank pa=
ge, if needed, that falls between them and Section 3, so that Section 3 sta=
rts on the front of the page, but continue the same page numbering without =
counting that blank page.

Output examples:

Section 1 =3D even
Section 2 =3D none
Section 3 =3D odd

Section 1 pages are numbered Page 1 of 7, through 4 of 7.
Section 3 pages are numbered Page 5 of 7 through 7 of 7 and there is a blan=
k page as physical and logical page 8.

Section 1 =3D even
Section 2 =3D none
Section 3 =3D even

Section 1 pages are numbered Page 1 of 8, through 4 of 8.
Section 3 pages are numbered Page 5 of 8 through 7 of 8. (There are 8 pages=
, both physically and logically)

Section 1 =3D odd
Section 2 =3D none
Section 3 =3D even

Section 1 pages are numbered Page 1 of 7, through 5 of 7.
Physical page 6 is a blank page that is not included in the total page coun=
t.
Section 3 pages are numbered Page 6 of 7 through 7 of 7,  as physical page =
8, and there is no blank page at the end.

Section 1 =3D odd
Section 2 =3D none
Section 3 =3D odd

Section 1 pages are numbered Page 1 of 8, through 5 of 8.
Physical page 6 is a blank page that is not included in the total page coun=
t.
Section 3 pages are numbered Page 6 of 8 through 7 of 8,  as physical page =
9, and there is a blank page at the end as physical page 10.

Section 1 =3D even
Section 2 =3D even
Section 3 =3D even

Section 1 pages are numbered Page 1 of 8, through 2 of 8.
Section 2 pages are numbered Page 3 of 8, through 4 of 8.
Section 3 pages are numbered Page 5 of 8 through 8 of 8 and there is no bla=
nk page at the end. (8 pages both physically and logically).

Section 1 =3D even
Section 2 =3D even
Section 3 =3D odd

Section 1 pages are numbered Page 1 of 7, through 2 of 7.
Section 2 pages are numbered Page 3 of 7, through 4 of 7.
Section 3 pages are numbered Page 5 of 7 through 7 of 7 and there is a blan=
k page as page 8 (both physically and logically).

Section 1 =3D even
Section 2 =3D odd
Section 3 =3D even

Section 1 pages are numbered Page 1 of 7, through 4 of 7.
Section 2 pages are numbered Page 5 of 7, through 5 of 7.
Physical page 6 is a blank page that is not included in the total page coun=
t.
Section 3 pages are numbered Page 6 of 7 through 7 of 7,  as physical page =
8, and there is no blank page at the end (end-on-odd) which is physical pag=
e 8 but logical page 7.

Section 1 =3D odd
Section 2 =3D even
Section 3 =3D even

Section 1 pages are numbered Page 1 of 7, through 3 of 7. (Ends on odd but =
no blank page inserted)
Section 2 pages are numbered Page 4 of 7, through 5 of 7.
Physical page 6 is a blank page that is not included in the total page coun=
t.
Section 3 pages are numbered Page 6 of 7 through 7 of 7,  as physical page =
8, and there is no blank page at the end (end-on-odd) which is physical pag=
e 8 but logical page 7.

Section 1 =3D odd
Section 2 =3D even
Section 3 =3D odd

Section 1 pages are numbered Page 1 of 8, through 3 of 8. (Ends on odd but =
no blank page inserted)
Section 2 pages are numbered Page 4 of 8, through 5 of 8.
Physical page 6 is a blank page that is not included in the total page coun=
t.
Section 3 pages are numbered Page 6 of 8 through 8 of 8,  as physical page =
9, and there is one blank page at the end (end-on-odd) which is physical pa=
ge 10 but logical page 9.

Section 1 =3D odd
Section 2 =3D odd
Section 3 =3D even

Section 1 pages are numbered Page 1 of 8, through 3 of 8. (Ends on odd but =
no blank page inserted)
Section 2 pages are numbered Page 4 of 8, through 4 of 8.
Section 3 pages are numbered Page 5 of 8 through 8 of 8. (8 pages both logi=
cally and physically)

Section 1 =3D odd
Section 2 =3D odd
Section 3 =3D odd

Section 1 pages are numbered Page 1 of 7, through 3 of 7. (Ends on odd but =
no blank page inserted)
Section 2 pages are numbered Page 4 of 7, through 4 of 7.
Section 3 pages are numbered Page 5 of 7 through 7 of 7. Blank page at end =
as page 8 both logically and physically.

Thank you,

Michelle

P.S. I hope I did this reply correctly so that it posts to the correct thre=
ad. This is my first time using an email chain forum.

-----Original Message-----
From: xsl-list-digest-help@lists.mulberrytech.com [mailto:xsl-list-digest-h=
elp@lists.mulberrytech.com]=20
Sent: Friday, June 08, 2012 10:10 PM
To: xsl-list@lists.mulberrytech.com
Subject: xsl-list Digest 9 Jun 2012 05:10:02 -0000 Issue 2850

Date: Fri, 08 Jun 2012 21:19:05 -0400
To: xsl-list@lists.mulberrytech.com,
 "'xsl-list@lists.mulberrytech.com'" <xsl-list@lists.mulberrytech.com>
From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
Subject: Re: [xsl] Trying to use fo:page-number-citation to set the
  initial-page-number of the next page-sequence
Message-Id: <7.0.1.0.2.20120608210915.02463a60@wheresmymailserver.com>

------------------------------

End of xsl-list Digest
***********************************

*****CONFIDENTIALITY  NOTICE*****

This e-mail may contain information that is privileged, confidential, or ot=
herwise exempt from disclosure under applicable law. If you are not the add=
ressee or it appears from the context or otherwise that you have received t=
his e-mail in error, please advise me immediately by reply e-mail, keep the=
 contents confidential, and immediately delete the message and any attachme=
nts from your system.=20

************************************

------------------------------

Date: Mon, 11 Jun 2012 15:41:36 -0400
To: xsl-list@lists.mulberrytech.com,
 "'xsl-list@lists.mulberrytech.com'" <xsl-list@lists.mulberrytech.com>
From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
Subject: Re: [xsl] RE: Trying to use fo:page-number-citation to set the
  initial-page-number of the next page-sequence
Message-Id: <7.0.1.0.2.20120611150803.0245c668@wheresmymailserver.com>

At 2012-06-11 11:55 -0700, Underwood Michelle wrote:
> >Unrelated to your question, for performance reasons on some
> >processors you might wish to review your use of "//" in the following:
>
>These are part of the generated code in the GUI development
>environment and I can't change them.

Ouch!  How unfortunate.  While there certainly are important
use-cases where "//" is the best way to get what you need, it is
unfortunate to see this construct abused in situations where it isn't
necessary.  I'm not saying this is one of those times ... it just
seems "lazy" to use it where it isn't appropriate, and for some
processors it may be expensive.

>I think the error message is because I 'hard-coded' that choose in
>there instead of using the GUI interface and the program doesn't like it.

Not every feels as I do, but I've never trusted any GUI to write XSLT
the way I would like XSLT to be written.  Some say that is simply my
bias for my teaching.

>Or, it could be that you can't nest choose statements. I'm not sure which.

One can certainly properly nest choose statements ... they have no
contextual restriction (beyond typical top-level constraints).  Just
remember that <xsl:choose> can only have <xsl:when> and
<xsl:otherwise> and those two constructs can only have <xsl:choose>
as their parent.

>My question is, why not as long as the referenced page number is
>generated before the referencing page? Is the value of the initial
>page number evaluated at transform or render?

Just the way the semantics were dictated by the designers of XSL-FO.

>I understand that the xslt processing happens at a different time
>than the xsl:fo processing (transform vs render) but I'm looking for
>a way to tell the renderer which initial page number to use based on
>the outcome of the xsl:choose so that the renderer either uses
>"auto" or looks at the page number of the referenced fo:block id to
>determine the starting page number of the next section if there is a
>blank page inserted between them.

Not in as many words, but I feel there must be a way to get what you
need with the existing semantics.

>Likewise, there must be a way to change the page force based on the
>outcome of the transform such as whether or not there is any content
>in Section 2.

Certainly there is ... you change the behaviour of page numbering
using XSL-FO semantics based on the XSLT determination of "the
presence of section 2" however you determine that.

>Here is the Use Case (or requirement statement), setup, and examples:
>
>I need a single output file that contains 2 or 3 sections having a
>common, continuous page numbering where Section 1 must have an
>initial page number of 1, start-on-odd, and, unless the optional
>Section 2 exists, end-on-even, but if Section 2 exists then Section
>1 and 2 must be continuous without blank pages between them and, in
>regards to page number and ending page force, become one Section,
>but because they may have slightly different footer content they
>must each have a separate static fo:block for the region-after, and
>when put together they must end-on-even so that Section 3 physically
>begins on an separate piece of paper when printed in duplex mode and
>will end-on-even, even if the logical page numbering says that this
>is an odd numbered page because the page numbering must logically
>start with the next page number that follows the end of Section 1-2
>regardless of whether a blank page is inserted before it causing
>there to be a difference between the physical page number and the
>logic page number.

Sounds like you may be unaware of force-page-count="no-force", which
is not the default.

So, for the first page-sequence (if using XSLT 2):

   initial-page-count="1"
   force-page-count="{ if ( {your-test-for-section-2-exists} )
                       then 'no-force' else 'end-on-even' }"

For the second section page sequence:

   force-page-count="end-on-even"

... so that the third section starts on the odd page number.

But note that if a blank even page is generated it's page number
cannot be skipped in the sequence ... the last page with content in
section two would have an odd page number and the first page of
section three would have the next odd page number.

You can turn blank-page generation off with "no-force" but you cannot
exclude blank-page generation from page-number counting.

Just the way it works.

>I am attempting to dynamically set the starting page numbers so that
>the "Page # of [total]" on each page accurately reflects only those
>pages which have content.

Using XSL-FO 1.1 you can cite the last page number of any section or
of the document ... but it isn't a count of "pages with content", it
is simply a count of pages.  You can skip the very last if it is a
blank, but you can't skip a middle page between sequences if it is a blank.

But with force-page-count="no-force", there are no middle blank pages.

>Here is what I am doing to attempt this:

Thanks for spelling it all out.

>...
>In other words, If Section 2 is included, Sections 1 and 2 flow
>together when printed in duplex (both sides of the paper) and insert
>only one blank page, if needed, that falls between them and Section
>3, so that Section 3 starts on the front of the page,

That is what I wrote out up above.

>but continue the same page numbering without counting that blank page.

That is something currently not available in XSL-FO.  You just cannot
request that.

But for duplex printing, I'm surprised you want continuous page
numbering not including blank pages because that would put even page
numbers on the "right hand side" of a bound set of folios.  Which is
not typical (and I find jarring when I've found it in newbie publications).

>Section 1 = odd
>Section 2 = none
>Section 3 = even
>
>Section 1 pages are numbered Page 1 of 7, through 5 of 7.
>Physical page 6 is a blank page that is not included in the total page count.
>Section 3 pages are numbered Page 6 of 7 through 7 of 7,  as
>physical page 8, and there is no blank page at the end.

Nope ... no can do with XSL-FO 1.1 ... blank pages participate in
page numbering.

>P.S. I hope I did this reply correctly so that it posts to the
>correct thread. This is my first time using an email chain forum.

Nope ... it looks like you broke the chain.  In MarkMail the old chain is here:

   http://markmail.org/message/hc2sp2zi6jxesbkh

... and this message seems to be in a new chain:

   http://markmail.org/message/c44jlh75jllvc5an

When I replied to your original message I did a "reply all", as I am
doing with this message, and we'll see if this gets added to the second chain.

I hope this has been helpful (even if it doesn't give you a
"standard" way out of your predicament).

. . . . . . . . . . . Ken

--
Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

------------------------------

Date: Mon, 11 Jun 2012 13:25:12 -0700 (PDT)
To: "xsl-list@lists.mulberrytech.com" <xsl-list@lists.mulberrytech.com>
From: Ming Yu <my600080@yahoo.com>
Subject: pass variable length parameters to java function
Message-ID: <1339446312.38418.YahooMailNeo@web39404.mail.mud.yahoo.com>

Is there a way to pass variable length of parameters to a java function lik=
e this from xslt?=0A=0A=A0 =A0public static void addToBatchBags(String ... =
values) {=0A=A0 =A0=A0=A0 for (String v : values ) {=0A=A0 =A0 =A0 =A0 // d=
o something=A0 =A0 =A0 =A0 =A0=0A=A0 =A0 =A0 }=0A=A0 =A0}=0A=0A=0AI tried t=
o call this function inside an xslt but it only allows me to pass one param=
eter.=0A=0AThanks!

------------------------------

Date: Mon, 11 Jun 2012 22:11:56 +0100
To: xsl-list@lists.mulberrytech.com
From: Michael Kay <mike@saxonica.com>
Subject: Re: [xsl] pass variable length parameters to java function
Message-ID: <4FD65F1C.7000900@saxonica.com>

Calling conventions from XSLT to Java depend entirely on which XSLT
processor you are using.

Michael Kay
Saxonica

On 11/06/2012 21:25, Ming Yu wrote:
> Is there a way to pass variable length of parameters to a java function like this from xslt?
>
>     public static void addToBatchBags(String ... values) {
>        for (String v : values ) {
>          // do something
>        }
>     }
>
>
> I tried to call this function inside an xslt but it only allows me to pass one parameter.
>
> Thanks!
>
> --~------------------------------------------------------------------
> 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@lists.mulberrytech.com>
> --~--
>
>

------------------------------

End of xsl-list Digest
***********************************


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS