This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Tabs


on 8/12/02 9:46 AM, sascha at sascha@assbach.de wrote:

> Hi,
> i have a problem transforming tabs into :fo, maybe i should better post this
> into the xsl:fo list , but i  guess it is more a XSLT thing:
> Here's my Input :
> 
> <richtext>
> <pardef id="2" leftmargin="0.3938in" tabs="L1.1806in L1.6729in L1.7715in
> L2.5590in L2.9521in"/>
> <par def="2">
> <run>
> <font name="Arial"/>   Tabbed Text</run>
> </par>
> ....
> </richtext>

I was hoping that someone would post an xsl solution before I offered my
solution. I think your problem results because you have a somewhat poorly
constructed xml document.

I wrote a little perl script that changes your original document from this:

<pardef id="2" leftmargin="0.3938in" tabs="L1.1806in L1.6729in L1.7715in
 L2.5590in L2.9521in"/>

To this:

<pardef id="2" leftmargin="0.3938in" tab1="L1806in" tab2="L1.6729in"
tab3="L1.7715in" tab4="L2.5590in" tab5="L2.2952in" num_of_tabs=5/>

I have made the script generic, so it could split any string in any tag. You
just provide the name of the tag, the attribut you want to split, and the
delimter (whether it is a space, or a capital "L" or what.) I could also put
in an extra two lines to strip the "L" and the "in" from the above strings.

The script is small, and if you have perl on your system, I can send it
along. That way, you have the information you need in an attribute, and you
just have to pick out this info to make your fo object.

Of course, you might not have perl. I know it is better to use xsl for
tranformations (especially on an xsl mailing list!), but sometimes pre-perl
processing can really simplify an xsl stylesheet.

Paul

> 
> There are 5 - left-tabs defined in the pardef with the same id that the
> actual par element has-
> refering to the pardef is done with something like:
> 
> <xsl:variable name='pabid'>
> <xsl:choose>
> <xsl:when test='@def'><xsl:value-of select='@def'/></xsl:when>
> <xsl:otherwise><xsl:value-of
> select='preceding-sibling::dxl:par[@def][1]/@def'/></xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
> ....
> 
> <xsl:when test="ancestor::dxl:richtext//dxl:pardef[@id=$pabid]/@tabs">
> 
> Then i have to split the tabs -string somehow.
> It seems that "tabs" are exported as special chars - how do i check this?
> and what special char it IS actually?
> And how do i count them? to make a reference to the left-margin i have to
> apply to the fo:block I am actually in-
> to make the text appear like tabbed at the right place?!
> Let's say i have entered 3 Tabs - so in my example i have to make the
> following output
> 
> <fo:block left-margin="1.7715in" font-face="Arial">Tabbed Text</fo:block>
> 
> ....something like that.
> 
> How do i get a XSLT that transforms my input to an fo: file that makes me
> get a correct PDF Output?
> Is there a way at all?
> 
> Thanks for your help!
> Sascha
> 
> 
> 
> 
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]