Hello,
my name is Andreas.
I work on an XSLT in order to convert my writings from OpenDocument to
XHTML.
Please bear in mind, that I am new to XSLT, so it might well be, that
this is not a problem at all, but as I understand XSLT now, the solution
to the problem I am going to outline now would require a more complex
language.
I tend to illustrate my texts with graphics. For this I use the
Insert-> Bitmap-> From File... menu. This will automatically surround
the bitmap with a frame. I use a flow-around for the frames.
Here is an excerpt of content.xml (sorry for eventual line-breaks, for
some reason Thunderbird ghosted the menu-entry to paste without
formatting). I will give an overview first:
In the document I have a "Heading 1" above a paragraph of text. Next to
the paragraph is the frame with the bitmap. For HTML this would ideally
result either in something like this:
<h1>Heading 1</h1>
<p>This is some text.</p>
<img src="" style="float:left;" />
or
<h1>Heading 1</h1>
<p>This is some text.
<img src="" style="float:left;" />
</p>
or the likes.
The ODF handles the layout of the XML as follows:
<text:h>
<draw:frame>
<draw:image />
</draw:frame>
Heading 1
</text:h>
Here is the code:
<text:h text:style-name="Heading_20_1"
text:outline-level="1"><draw:frame draw:style-name="fr2"
draw:name="Grafik1" text:anchor-type="paragraph" svg:x="2.27cm"
svg:y="2.057cm" svg:width="5.689cm" style:rel-width="22%"
svg:height="5.539cm" style:rel-height="scale"
draw:z-index="11"><draw:image
xlink:href="Pictures/100000000000012C0000012CBED4AE2D.jpg"
xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
</draw:frame>Mythen</text:h>
To me this looks messed up a little. There is no indication in the
actual document, that the draw-frame is part of the heading. /If/ part
of anything, then it could be part of the paragraph only.
Now I can imagine how difficult this is for the programmers behind OOo...
With a relative simple XSLT I get an (invalid) XHTML result like this:
<h1 class="Heading_20_1">
<div class="fr2" style="border:1px black solid; width:5.689cm;
height:5.539cm; z-index:11; float:right; margin:20px;">
</div>
Mythen
</h1>
The XSLT for that is:
<xsl:template match="draw:frame">
<div class="[EMAIL PROTECTED]:style-name}" style="border:1px black solid;
width:[EMAIL PROTECTED]:width}; height:[EMAIL PROTECTED]:height};
z-index:[EMAIL PROTECTED]:z-index};
float:right; margin:20px;">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="text:h" name="h">
<h1 class="[EMAIL PROTECTED]:style-name}"><xsl:apply-templates/></h1>
</xsl:template>
At another place, in the same document:
<text:p>
<draw:frame>
<draw:text-box>
<text:p>
<draw:frame> <draw:image /> </draw:frame>
<text:sequence>1</text:sequence>
Scene from the Motion Picture „Brazil“
</text:p>
</draw:text-box>
</draw:frame>
Here comes the paragraph text, foo bar, batz...
</text:p>
<text:p text:style-name="Text_20_body"><draw:frame draw:style-name="fr4"
draw:name="Abbildung1" text:anchor-type="paragraph" svg:x="15.665cm"
svg:y="0.314cm" svg:width="10.261cm" draw:z-index="5">
<draw:text-box fo:min-height="6.93cm">
<text:p text:style-name="Illustration"><draw:frame
draw:style-name="fr3" draw:name="Shogun" text:anchor-type="paragraph"
svg:x="-0.252cm" svg:y="-0.252cm" svg:width="10.156cm"
svg:height="6.064cm" draw:z-index="6"><draw:image
xlink:href="Pictures/1000000000000120000000AC322E03C8.jpg"
xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
</draw:frame>Abbildung <text:sequence
text:ref-name="refIllustration0" text:name="Illustration"
text:formula="ooow:Illustration+1"
style:num-format="1">1</text:sequence>: Scene from the Motion Picture
„Brazil“</text:p>
</draw:text-box>
</draw:frame>Here comes the paragraph text, foo bar, batz...</text:p>
Logically the picture is not part of the paragraph, just as the picture
before was not part of the heading. Here layout and content mix in the
XML and I would suppose this should not be the case.
I also do not find a way to apply an XSLT on this.
I would need to implment a fallback template for such cases, where I can
extract all, that is _before_ </text:*> but after </draw:frame>.
However, this seems hackish to me.
For the last example I use the same construct as for the first, just
exchanging <text:h> with <text:p>.
Thanks.
--
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]