XPath namespace exception

2 views
Skip to first unread message

Ashok Hariharan

unread,
Jun 9, 2009, 11:52:39 AM6/9/09
to akomantoso-dev
Luca:

I am getting a namespace exception on the XPathResolver class :

It seems to be related to the "xsl:" namespace prefix in the mini xslts ... I am not getting it on mac os x, but on Ubuntu - which is running Jdk 6...


javax.xml.transform.TransformerException: Prefix must resolve to a namespace:
    at com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathParser.java:602)
    at com.sun.org.apache.xpath.internal.compiler.Lexer.mapNSTokens(Lexer.java:638)
    at com.sun.org.apache.xpath.internal.compiler.Lexer.tokenize(Lexer.java:265)
    at com.sun.org.apache.xpath.internal.compiler.Lexer.tokenize(Lexer.java:96)
    at com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(XPathParser.java:108)
    at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:162)
    at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:198)
    at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:394)
    at org.un.bungeni.translators.utility.xpathresolver.XPathResolver.evaluate(XPathResolver.java:92)
    at org.un.bungeni.translators.odttoakn.translator.OAPipelineResolver.resolve(OAPipelineResolver.java:103)
    at org.un.bungeni.translators.odttoakn.translator.OATranslator.buildXSLT(OATranslator.java:361)
    at org.un.bungeni.translators.odttoakn.translator.OATranslator.translate(OATranslator.java:129)
    at org.bungeni.plugins.translator.OdtTranslate.exec(OdtTranslate.java:61)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.bungeni.editordispatch.test.run(test.java:74)
    at org.bungeni.editordispatch.test.main(test.java:83)
--------------- linked to ------------------
javax.xml.xpath.XPathExpressionException
    at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:402)
    at org.un.bungeni.translators.utility.xpathresolver.XPathResolver.evaluate(XPathResolver.java:92)
    at org.un.bungeni.translators.odttoakn.translator.OAPipelineResolver.resolve(OAPipelineResolver.java:103)
    at org.un.bungeni.translators.odttoakn.translator.OATranslator.buildXSLT(OATranslator.java:361)
    at org.un.bungeni.translators.odttoakn.translator.OATranslator.translate(OATranslator.java:129)
    at org.bungeni.plugins.translator.OdtTranslate.exec(OdtTranslate.java:61)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.bungeni.editordispatch.test.run(test.java:74)
    at org.bungeni.editordispatch.test.main(test.java:83)


Luca Cervone

unread,
Jun 9, 2009, 11:58:44 AM6/9/09
to akomant...@googlegroups.com
Ashok, 
Let me see into it tonight or tomorrow. 
I have to finish a job before 22 o'clock and then I can see into it. 

However I think  that the error that you submitted to me yesterday (regarding the AKN->HTML translator), is due to the fact that the translator do not find the source AKOMA NTOSO document or some of the mini XSLT. 

I'll see into this new error tonight. 

Ciao
Luca
Luca Cervone
Web and XML solutions designer

e-mail:     cervo...@gmail.com

mobile phone:    0039 348 26 27 545
home   phone:  0039 051 199 82 854

skype:   cervoneluca



Ashok Hariharan

unread,
Jun 10, 2009, 2:58:04 AM6/10/09
to akomant...@googlegroups.com


On Tue, Jun 9, 2009 at 6:58 PM, Luca Cervone <cervo...@gmail.com> wrote:

However I think  that the error that you submitted to me yesterday (regarding the AKN->HTML translator), is due to the fact that the translator do not find the source AKOMA NTOSO document or some of the mini XSLT. 

I'll see into this new error tonight. 


I ll try and send you a test case for this problem ...

Ashok

Ashok Hariharan

unread,
Jun 10, 2009, 8:45:23 AM6/10/09
to akomant...@googlegroups.com
Luca,

I dont get the error if i build from source the translator on ubuntu -- so that issue is OK for the moment.

The other issue i am having is that the translation output is wrong .. see the xml pasted below .. it has 2 <meta> blocks one at the start of the file and the second at the end of the file -- i am getting this error on both ubuntu and mac os x
.

I remember seeing this problem before but couldnt simulate it again - but now i am getting this even for the unit tests.

<?xml version="1.0" encoding="UTF-8"?><akomaNtoso xmlns="http://www.akomantoso.org/1.0">
   <debateRecord>
      <meta>
         <identification source="#bungeni">
            <FRBRWork>
               <this value="/ken/debaterecord/2008-12-16/main"/>
               <uri value="/ken/debaterecord/2008-12-16"/>
               <date date="2008-12-17" name="workDate"/>
               <author href="#clerk.aClerk"/>
            </FRBRWork>
            <FRBRExpression>
               <this value="/ken/debaterecord/2008-12-16/eng@/main"/>
               <uri value="/ken/debaterecord/2008-12-16/eng@"/>
               <date date="2008-12-16" name="expDate"/>
               <author href="#user.Ashok"/>
            </FRBRExpression>
            <FRBRManifestation>
               <this value="/ken/debaterecord/2008-12-16/eng@/main.xml"/>
               <uri value="/ken/debaterecord/2008-12-16/eng@.akn"/>
               <date date="2008-12-16" name="manDate"/>
               <author href="#user.Ashok"/>
            </FRBRManifestation>
         </identification>
         <publication date="2008-12-17" name="Debate Record" showAs=""/>
         <references source="#bungeni">
            <TLCOrganization id="Parliament" href="2" showAs="Parliament"/>
            <TLCPerson id="clerk.aClerk" href="clerk.aClerk" showAs="Author"/>
            <TLCPerson id="user.Ashok" href="user.Ashok" showAs="Author"/>
            <TLCPerson id="4" href="ken.person.Francis.Acheka.1951-12-10" showAs="Francis Acheka"/>
            <TLCPerson id="2" href="ken.person.Francis.NoKibaki.1951-12-08" showAs="Francis NoKibaki"/>
            <TLCPerson id="305" href="ken.person.Kipkalia.Tegere.1945-03-10" showAs="Kipkalia Tegere"/>
         </references>
      </meta>
      <p/>
      <p>NATIONAL ASSEMBLY</p>
      <p/>
      <p>OFFICIAL REPORT</p>
      <p/>
      <p>Thursday 17<span>th</span>December 2008</p>
      <p/>
      <p>The House met at8:22</p>
      <p/>
      <p/>
      <p>[Mr. Deputy Speaker in the Chair]</p>
      <p/>
      <p>PRAYERS</p>
      <p/>
      <heading>PAPERS LAID</heading>
      <subheading>The following Papers were laid on the Table:-</subheading>
      <list id="d1e311">
         <item id="d1e312">
            <p>The Report of the Commonwealth Parliamentary Association (CPA) Kenya branch delegation to the 35th CPA (Africa Region) conference held in Lobamba, Swaziland from 7th August, 2004 to 15th August, 2004.</p>
         </item>
         <item id="d1e315">
            <p>The Report of the 45th Session of the Executive Committee and the 27th Conference of the African Parliamentary Union held in Algiers, Algeria on 27th November, 2004, to 1st December, 2004.</p>
         </item>
      </list>
      <p/>
      <p>(By Mr. Khamasi)</p>
      <p/>
      <p/>
      <list id="d1e328">
         <item id="d1e329">
            <p>The Report of the first and second sessions of the Pan-African Parliament of the African Union.</p>
         </item>
      </list>
      <p/>
      <p/>
      <p>(By the Assistant Minister</p>
      <p>for Finance (Mr. Obwocha)</p>
      <p/>
      <p/>
      <list id="d1e346">
         <item id="d1e347">
            <p>The Annual Report and Accounts of Moi Teaching and Referral Hospital for the year ended 30th June, 2001 and the Certificate thereof by the Controller and Auditor-General.</p>
         </item>
      </list>
      <p/>
      <p/>
      <p>(By the Assistant Minister for</p>
      <p>Finance (Mr. Obwocha) on behalf</p>
      <p>of the Minister for Health)</p>
      <p/>
      <heading>NOTICES OF MOTIONS</heading>
      <p/>
      <p/>
      <heading>Adoption of 35TH CPA(Africa Region) Report</heading>
      <p/>
      <p>Mr Acheka:</p>
      <p/>
      <p>Mr. Deputy Speaker, Sir, I beg to give notice of the following Motions:-</p>
      <p>THAT, this House adopts the Report of the Commonwealth Parliamentary Association (CPA), Kenya Branch delegation to the 35th CPA Africa Region Conference held in Lobamba, Swaziland from 7th August, 2004 to 15th August, 2004 laid on the Table of the House on Thursday, 9th December, 2004.</p>
      <p/>
      <heading>Adoption of Report of First and Second Sessions of Pan African Parliament</heading>
      <p>
         <span>Mr. NoKibaki</span>
         <span>(Assistant Minister of Finance)</span>
      </p>
      <p/>
      <p>Mr. Deputy Speaker, Sir, I beg to give notice of the following Motion:-</p>
      <p>THAT, this House adopts the Report of the first and second sessions of the Pan African Parliament of the African Union laid on the Table of this House on Thursday, 9th December, 2004.</p>
      <p/>
      <p/>
      <p/>
      <heading>ADJOURNEMENT</heading>
      <p>
         <span>Mr.Dy Speaker</span>
         <span>(</span>
         <span>Mr.Tegere)</span>
      </p>
      <p>
         <span>Hon. Members, the House is, therefore adjorned</span>
         <span>sine die</span>
         <span>.</span>
      </p>
      <p/>
      <p/>
      <p>The House rose at9.50 p.m.</p>
      <p/>
      <p/>
      <p/>
      <p/>
      <meta>
         <identification source="#bungeni">
            <FRBRWork>
               <this value="/ken/debaterecord/2008-12-16/main"/>
               <uri value="/ken/debaterecord/2008-12-16"/>
               <date date="2008-12-17" name="workDate"/>
               <author href="#clerk.aClerk"/>
            </FRBRWork>
            <FRBRExpression>
               <this value="/ken/debaterecord/2008-12-16/eng@/main"/>
               <uri value="/ken/debaterecord/2008-12-16/eng@"/>
               <date date="2008-12-16" name="expDate"/>
               <author href="#user.Ashok"/>
            </FRBRExpression>
            <FRBRManifestation>
               <this value="/ken/debaterecord/2008-12-16/eng@/main.xml"/>
               <uri value="/ken/debaterecord/2008-12-16/eng@.akn"/>
               <date date="2008-12-16" name="manDate"/>
               <author href="#user.Ashok"/>
            </FRBRManifestation>
         </identification>
         <publication date="2008-12-17" name="Debate Record" showAs=""/>
         <references source="#bungeni">
            <TLCOrganization id="Parliament" href="2" showAs="Parliament"/>
            <TLCPerson id="clerk.aClerk" href="clerk.aClerk" showAs="Author"/>
            <TLCPerson id="user.Ashok" href="user.Ashok" showAs="Author"/>
            <TLCPerson id="4" href="ken.person.Francis.Acheka.1951-12-10" showAs="Francis Acheka"/>
            <TLCPerson id="2" href="ken.person.Francis.NoKibaki.1951-12-08" showAs="Francis NoKibaki"/>
            <TLCPerson id="305" href="ken.person.Kipkalia.Tegere.1945-03-10" showAs="Kipkalia Tegere"/>
         </references>
      </meta>
   </debateRecord>
</akomaNtoso>

Luca Cervone

unread,
Jun 10, 2009, 8:52:04 AM6/10/09
to akomant...@googlegroups.com
Dear Ashok, 
This seems the same error that you had few days ago. 
It is due to the fact that the translator did not found some of the mini XSLT. 
If I'm not wrong the last time you discovered that you were reading the mini XSLT from a wrong directory. 

Let me know. 

Ciao
Luca

Ashok Hariharan

unread,
Jun 10, 2009, 9:07:44 AM6/10/09
to akomant...@googlegroups.com
On Wed, Jun 10, 2009 at 3:52 PM, Luca Cervone <cervo...@gmail.com> wrote:
Dear Ashok, 
This seems the same error that you had few days ago. 
It is due to the fact that the translator did not found some of the mini XSLT. 
If I'm not wrong the last time you discovered that you were reading the mini XSLT from a wrong directory. 


I wasnt sure why it was happening last time -- i have checked the paths -- i even checked out a fresh from svn -- its getting the minixslt from the right location.

the problem seems to me one of namespaces in pipeline.xsl where there is a non prefixed foreign namespace (xslt) mixed with  a prefixed namespace (xsl:....) and some of the xpath matches are being thrown up incorrectly ...


 

Luca Cervone

unread,
Jun 10, 2009, 9:28:42 AM6/10/09
to akomant...@googlegroups.com
Ashok,
Can you send to me the pipeline? 
I really don't know what happening. The only thing that can be is that some xslt are missing. 
Infact in the document that you send the empty <p> are not deleted and the conlcusion is missing. 

The translator on my laptop is working well. 
Let me see the pipeline please so I can understand better. 

Ciao
Luca

Ashok Hariharan

unread,
Jun 10, 2009, 9:41:43 AM6/10/09
to akomant...@googlegroups.com
On Wed, Jun 10, 2009 at 4:28 PM, Luca Cervone <cervo...@gmail.com> wrote:
Ashok,
Can you send to me the pipeline? 
I really don't know what happening. The only thing that can be is that some xslt are missing. 
Infact in the document that you send the empty <p> are not deleted and the conlcusion is missing. 

Attached ...
 

The translator on my laptop is working well. 
Let me see the pipeline please so I can understand better. 


Thats the problem... it works for me sometimes ... sometimes it doesnt - under the same test scenarios...

I think the program actually throws an exception somewhere but since we are not logging them its hard to tell..
pipeline.xsl

Luca Cervone

unread,
Jun 10, 2009, 9:49:19 AM6/10/09
to akomant...@googlegroups.com
Dear Ashok, 
As I supposed the pipeline is broken. 
You have only 40 step against 137 in the mine one. 

I still think that you are not using an updated set of  miniXSLT

I attach my pipeline. 



pipeline.xsl

Ashok Hariharan

unread,
Jun 10, 2009, 9:55:59 AM6/10/09
to akomant...@googlegroups.com
The one i sent you is the one from svn :

http://code.google.com/p/bungeni-portal/source/browse/DocTransforms/trunk/ODTtoAKN/resources/odttoakn/minixslt/debaterecord/pipeline.xsl

it has 40 steps ... ?

Ashok

<pipeline.xsl>

Luca Cervone

unread,
Jun 10, 2009, 10:08:19 AM6/10/09
to akomant...@googlegroups.com
Dear Ashok, 
I don't know how it is possible. 
I attach my resource folder. 
Eclipse says to me that the code on the SVN is correctly updated :-O

It is possible that the .DS_Store are of MAC OS X causes some strange bug of google code when I commit the code?

That's the only thing I can think ...

However, now I'm using eclipse to send some files on a server and this will take a bit of time. Then I'll try to commit again the code. 

In the meanwhile you can try to use the resources attached ... they should work

Let me know,  and sorry but really I don't know what google code is doing. 

ciao
Luca
 
resources.zip

Luca Cervone

unread,
Jun 10, 2009, 10:10:27 AM6/10/09
to akomant...@googlegroups.com
Ashok please, achieve to me that you received my previous email? the attached file was 2.2M big so i don't know if you received it. 

Thanks
Ciao
Luca

Ashok Hariharan

unread,
Jun 10, 2009, 10:32:41 AM6/10/09
to akomant...@googlegroups.com
thanks, i got it ...

Ashok Hariharan

unread,
Jun 10, 2009, 11:02:56 AM6/10/09
to akomant...@googlegroups.com
Perhaps you should do a fresh checkin into this repository to make a
fresh start :

http://bungeni-editor.googlecode.com/svn/plugins/OdtTransformer

i have a separate google code project for the editor

http://code.google.com/p/bungeni-editor

so it kinda makes sense to move it from the
bungeni-portal.googlecode.com repository ...

Ashok Hariharan

unread,
Jun 11, 2009, 4:56:13 AM6/11/09
to akomant...@googlegroups.com
Luca,

There is some basic miscommunication ...

The link i sent you to the pipeline with 40 steps was for odt-> akn.

You sent me back a pipeline with 120 steps which is for akn -> html

As I said earlier -- the odt -> akn transform isnt generating correct
output so clearly the problem is in the odt -> akn pipeline.

I am again attaching the xml output to higlight the problem.

I get this output by running the default unit test.

Ashok
resultAKN_db.xml

Luca Cervone

unread,
Jun 11, 2009, 5:08:26 AM6/11/09
to akomant...@googlegroups.com
Dear Ashok, 
First of all I cleaned up my project and committed again the whole sources. 

I run I test and everything works well.
Can you please update the sources ant try to run again the test?

Let me know if now it works.
Ciao
Luca
  

<resultAKN_db.xml>

Ashok Hariharan

unread,
Jun 11, 2009, 6:04:42 AM6/11/09
to akomant...@googlegroups.com
Luca,

Now i am able to simulate the problem better --

I am running Java 5 (version 1.5.0_16) on mac os x (this is the mac os
x default and the project default).

When i run the transform using java 5 -- i get the wrong output (see attached).

I switched the active platform in eclipse to java 6 (version 1.6.0_7)
and i rebuilt the project,
and now i get the correct output on java 6 -- (see attached).

The problem is there is a bug in your usage of the Prefix Resolver --

You are doing this (see code extract below) -- the PrefixResolver and
PrefixResolverDefault that you are using is the one from Xalan
(com.sun.org.apache.xml.internal.....), and you are using the Xalan
prefix resolver with Saxon. This does not work in many versions of jdk
5 (i simulated the same problem on ubuntu using different jvm
platforms).

If you look at the Saxon documentation the recommended method is to
use the PrefixResolver from the excalibur.apache.org project (which is
an updated version of Xalan - and is the one used in Java 6)...

So i would suggest that you either switch your transforms project to
java 6 for now -- and subsequently replace the prefixresolverdefault
with an explicit override of the namespace prefixes....

<code>
import com.sun.org.apache.xml.internal.utils.PrefixResolver;
import com.sun.org.apache.xml.internal.utils.PrefixResolverDefault;

......

final PrefixResolver resolver = new
PrefixResolverDefault(aDocument.getDocumentElement());
NamespaceContext specificRulesNSC = new NamespaceContext()
{
public String getNamespaceURI(String prefix)
{
return resolver.getNamespaceForPrefix(prefix);
}

public Iterator<?> getPrefixes(String val)
{
return null;
}

public String getPrefix(String uri)
{
return null;
}
};
</code>


Ashok
java5_debaterecord_ken_eng_2008_12_17_main.xml
java6_debaterecord_ken_eng_2008_12_17_main.xml

Luca Cervone

unread,
Jun 11, 2009, 6:16:48 AM6/11/09
to akomant...@googlegroups.com
Dear Ashok, 
Thank you. 
But I have to say that I always used JAVA 6 as we discussed in our arguing before the start of the project :-) 

By the way, The important thing is that now always works fine. 
Now I'm very very near to commit the new code with the localisation strings in properties files. 

In the meanwhile can we start an arguing about the things that are missing in the translator? 

If I'm not wrong the only things that are still incomplete (leaving out the localised string in the properties files) are:

- the error messages for the missing elements in the content and in the metadata
- the identification of the mini XSLT that must be changed according to the new version of AKOMA NTOSO. 

Am I forgetting something?

Let me know.

ciao
Luca


<java5_debaterecord_ken_eng_2008_12_17_main.xml><java6_debaterecord_ken_eng_2008_12_17_main.xml>
Reply all
Reply to author
Forward
0 new messages