XML Web Application For Idea Management System

xhtml, xml, xslt No Comments

Managed to complete one of my project for this semester.

Page are generated from xslt process and rendered to xhtml format. Page navigations are controlled using xAjax component.

Try it out and have fun :D
http://www.lindaocta.com/linda/stuff/xmlAssignment/index.php

Exporting to pdf from Open office Writer

MS Office, Open Office, xml No Comments

One of main reason for me to choose Open Office over Microsoft Words is that I can convert my document to PDF without installing (or buying) other software. As for my work at Uni, Open Office is main tools used by our clients to create their documents and I have been hacking around with Open Office xml files to meet the customer expectation.

When I play around with Open Office fonts today, I found out one bug when I try to export one of my client’s document to PDF. The document is successfully exported to PDF, but some of the characters are missing in the PDF file. I have been sitting in front of my computer try to figure out why the characters are gone where as when I created a new document with those characters, they appear in the PDF file. Sitting the whole two hours trying to compare the style.xml (I crashed vim and crimson editor for at least 20 times because my box has only 512 RAM and style.xml consists too many lines) and content.xml files, and finally I managed to work out why the characters are not included in the PDF file.

You can replicate the problem by doing these step: :D

  1. Create writer document
  2. Put some text in with an “en dash” (–) character. You can insert this character from open office using <Alt> + <0150> on your number keypad or <Ctrl> + <-> (May not work in some dialog boxes).
  3. Select all the text (including “en dash” character) and change the font to “Helvetica” (only).
  4. Save the document and start to export the document to PDF
  5. Open the PDF file and your “en dash characters are gone”

The error is found for document created in Words opened and exported in Open Office with the above font as well. I don’t know if this is an open office bug as “Helvetica” (standard “Arial” font in Neo Office) is not belong to font list (there is only “Helvetica-Narrow”) because after I replace the style to Helvetica-Narrow the “en dash” appear in the PDF.

Modification that I made in style.xml file is changing:

<style:text-properties style:font-name=”Helvetica” fo:font-size=”8.5pt” fo:font-style=”normal”/>

to:

<style:text-properties style:font-name=”Helvetica-Narrow” fo:font-size=”8.5pt” fo:font-style=”normal”/>

I try to search of the issue report in open office, and seems like this issue had been reported previously related Helvetica included in PDF export in Issue 81970. I have reported the issue to Open Office (Issue 82540) and still waiting for the response ;) . My client insists on using Helvetica (only) font even Arial has the same view because changing the font name may break other system that use the same document.

Few hours later….

As I predicted, Open office closed Issue 82540 and suggested to use other font that is supported by Open office like “Helvetica-Narrow”. Well, I think that will be the solution for my case for a time being. :(

xsd:key and xsd:keyref

xml No Comments

One of my master project is using xml to create a website. As I understand using xsd:key and xsd:keyref are easy if the primary key and foreign key are existed in the same xml file. What I am trying to do below are separating the document into two xml file and for the schema, the foreign key of one schema will point to primary key of another schema, but my schema validation is not giving me a right result :P .

Below are the summarize of my xml file:

primary.xsd
<xsd:key name=”uniqueUserId”>
<xsd:selector xpath=”.//user/userId”/>
<xsd:field xpath=”.”/>
</xsd:key>

with primary.xml
<userList>
<user><userId>1</userId></user>
<user><userId>2</userId></user>
</userList>

When I validate the above primary.xml against primary.xsd (using xmllint), my data is valid. Note: that above xsd:key also check for duplicate.

foreign.xsd
<xsd:include schemaLocation=”user.xsd” />
<xsd:keyref name=”refUserId” refer=”uniqueUserId”>
<xsd:selector xpath=”idea/userId”/>
<xsd:field xpath=”.”/>
</xsd:keyref>

foreign.xml
<ideaList>
<idea><ideaId>1</ideaId><userId>1</userId></idea>
<idea><ideaId>2</ideaId><userId>2</userId></idea>
<idea><ideaId>3</ideaId><userId>3</userId></idea>
</ideaList>

When I validate foreign.xml against foreign.xsd using xmllint –schema foreign.xsd foreign.xml, i get below error (the correct answer should be only for ideaId=3 since userId 3 is not exist):

foreign.xml:12: Schemas validity error : Element ‘userId’: No match found for key-sequence ['1'] of keyref ‘refUserId’.
foreign.xml:18: Schemas validity error : Element ‘userId’: No match found for key-sequence ['2'] of keyref ‘refUserId’.
foreign.xml:24: Schemas validity error : Element ‘userId’: No match found for key-sequence ['3'] of keyref ‘refUserId’.

I am trying to sort the problem till now. Any help will be appreciated :)