Loading ...
Sorry, an error occurred while loading the content.

Re: cross referencing within a document using xref

Expand Messages
  • mina_hurray
    Thank you very much for your help on this. It worked for me.
    Message 1 of 5 , Mar 22, 2007
    • 0 Attachment
      Thank you very much for your help on this. It worked for me.


      --- In XSL-FO@yahoogroups.com, "G. Ken Holman" <gkholman@...> wrote:
      >
      > At 2007-03-19 12:03 -0700, ms wrote:
      > >I tried the code that you gave me and it worked. I
      > >have just one more question for you. I have mentioned
      > >only three levels in this example. However, in my
      > >document I can have up to 6 levels.
      > >
      > >The formatting used is:
      > >
      > >level1 - 1
      > >level2 - A
      > >level3 - (1)
      > >level4 - (a)
      > >level5 - 1)
      > >level6 - a
      > >
      > >Now I modified the xref template format to:
      > >
      > > <xsl:template match="xref">
      > > <xsl:for-each select="key( 'steps',@ xrefid)">
      > ><xsl:number level="multiple"
      > >count="level1| level2 | level3|level4|level5|level6"
      > >format="1.A.(1).(a).1).a."/>
      > >
      > ></xsl:for-each>
      > > </xsl:template>
      > >Is this the correct way? I basically want to enforce
      > >the formatting numbers to be the same if a sixth level
      > >is referenced.
      > >So i want somehtinglike 1.C.(5).(a).1).a.
      > >
      > >If it is at a third level I want:
      > >
      > >1.C.(5).
      > >
      > >Please tell me if I what I am doing is right.
      >
      > Close but there is a nuance that I neglected last time. You cannot
      > easily get the trailing ")" after the "5" because it is considered
      > part of the prefix ")." to the "a". See the mina.xsl and mina.out
      > below for the effect. Note that the trailing "." on level 3 is the
      > "." at the end of the pattern.
      >
      > Since you have suffixes as well as prefixes in middle levels it will
      > have to be more complex than a simple use of <xsl:number>. See
      > mina2.xsl and mina2.out below for a complete solution. You will see
      > that I was able to combine levels 1 and 2 because of the simple
      > formatting, but I had to break out levels 3-6 because of the prefixes
      > and suffixes.
      >
      > I hope this helps.
      >
      > . . . . . . . . . . . . . Ken
      >
      >
      > t:\ftemp>type mina.xml
      > <test>
      > <level1 id="123">
      > <text>This is a step. </text>
      > <level2/>
      > <level2/>
      > <level2 id="234">
      > <text> Anther level </text>
      > <level3/>
      > <level3/>
      > <level3/>
      > <level3/>
      > <level3 id="345">
      > <text>One more level inside level2. </text>
      > <level4 id="456">
      > <text>This is a step. </text>
      > <level5 id="567">
      > <text> Anther level </text>
      > <level6 id="678">
      > <text>One more level inside level5. </text>
      > </level6>
      > </level5>
      > </level4>
      >
      > <level4 id="789">
      > <text>This is a step which refers levels:</text>
      > <xref xrefid="123"/>
      > <xref xrefid="234"/>
      > <xref xrefid="345"/>
      > <xref xrefid="456"/>
      > <xref xrefid="567"/>
      > <xref xrefid="678"/>
      > <level5>
      > <text> Anther level5 </text>
      > </level5>
      > </level4>
      > </level3>
      > </level2>
      > </level1>
      > </test>
      >
      >
      >
      > t:\ftemp>type mina.xsl
      > <?xml version="1.0" encoding="US-ASCII"?>
      > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      > version="1.0">
      >
      > <xsl:output method="text"/>
      >
      > <xsl:key name="steps" match="*[@id]" use="@id"/>
      >
      > <xsl:template match="xref">
      > <xsl:for-each select="key('steps',@xrefid)">
      > <xsl:number level="multiple"
      > count="level1 | level2 | level3 | level4 | level5
      | level6"
      > format="1.A.(1).(a).1).a."/>
      > </xsl:for-each>
      > </xsl:template>
      >
      > </xsl:stylesheet>
      >
      >
      > t:\ftemp>call xslt mina.xml mina.xsl mina.out
      >
      > t:\ftemp>type mina.out
      >
      >
      > This is a step.
      >
      >
      >
      > Anther level
      >
      >
      >
      >
      >
      > One more level inside level2.
      >
      > This is a step.
      >
      > Anther level
      >
      > One more level inside level5.
      >
      >
      >
      >
      >
      > This is a step which refers levels:
      > 1.
      > 1.C.
      > 1.C.(5.
      > 1.C.(5).(a.
      > 1.C.(5).(a).1.
      > 1.C.(5).(a).1).a.
      >
      > Anther level5
      >
      >
      >
      >
      >
      >
      > t:\ftemp>type mina2.xsl
      > <?xml version="1.0" encoding="US-ASCII"?>
      > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      > version="1.0">
      >
      > <xsl:output method="text"/>
      >
      > <xsl:key name="steps" match="*[@id]" use="@id"/>
      >
      > <xsl:template match="xref">
      > <xsl:for-each select="key('steps',@xrefid)">
      > <xsl:choose>
      > <xsl:when test="self::level1 or self::level2">
      > <xsl:number level="multiple"
      > count="level1 | level2"
      > format="1.A."/>
      > </xsl:when>
      > <xsl:when test="self::level3">
      > <xsl:number level="multiple"
      > count="level1 | level2 | level3"
      > format="1.A.(1)."/>
      > </xsl:when>
      > <xsl:when test="self::level4">
      > <xsl:number level="multiple"
      > count="level1 | level2 | level3 | level4"
      > format="1.A.(1).(a)."/>
      > </xsl:when>
      > <xsl:when test="self::level5">
      > <xsl:number level="multiple"
      > count="level1 | level2 | level3 | level4 | level5"
      > format="1.A.(1).(a).1)."/>
      > </xsl:when>
      > <xsl:when test="self::level6">
      > <xsl:number level="multiple"
      > count="level1 | level2 | level3 | level4 |
      > level5 | level6"
      > format="1.A.(1).(a).1).a."/>
      > </xsl:when>
      > </xsl:choose>
      > </xsl:for-each>
      > </xsl:template>
      >
      > </xsl:stylesheet>
      >
      >
      > t:\ftemp>call xslt mina.xml mina2.xsl mina2.out
      >
      > t:\ftemp>type mina2.out
      >
      >
      > This is a step.
      >
      >
      >
      > Anther level
      >
      >
      >
      >
      >
      > One more level inside level2.
      >
      > This is a step.
      >
      > Anther level
      >
      > One more level inside level5.
      >
      >
      >
      >
      >
      > This is a step which refers levels:
      > 1.
      > 1.C.
      > 1.C.(5).
      > 1.C.(5).(a).
      > 1.C.(5).(a).1).
      > 1.C.(5).(a).1).a.
      >
      > Anther level5
      >
      >
      >
      >
      >
      >
      > t:\ftemp>echo Done!
      > Done!
      >
      >
      > --
      > World-wide corporate, govt. & user group XML, XSL and UBL training
      > RSS feeds: publicly-available developer resources and training
      > G. Ken Holman mailto:gkholman@...
      > Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
      > Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
      > Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/f/bc
      > Legal business disclaimers: http://www.CraneSoftwrights.com/legal
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.