other issues ...

0 views
Skip to first unread message

Ashok Hariharan

unread,
Jun 9, 2009, 12:02:36 PM6/9/09
to akomantoso-dev
1) Readabiltiy

I found some of the source code unreadable...

e.g.

  //apply the XSLT to the document
   StreamSource result = XSLTTransformer.getInstance().transform(new StreamSource(metalexFile), new StreamSource(xslt));
               
  //apply to the result the XSLT that insert the namespace
   StreamSource resultWithNamespace = XSLTTransformer.getInstance().transform(result, new StreamSource(new File(this.akomantosoAddNamespaceXSLTPath)));
               
I have made it more readable and easier to debug  :

//Stream for metalex file
 StreamSource ssMetalex = new StreamSource(metalexFile);

 //streamsource to xslt that transforms the metalex
 StreamSource ssXslt = new StreamSource(xslt);
                                       
  XSLTTransformer xsltTransformer = XSLTTransformer.getInstance();
//apply the XSLT to the document
StreamSource result = xsltTransformer.transform(ssMetalex, ssXslt);

 //stream the AN xslt file
StreamSource ssAnXsltpath = new StreamSource(new File(this.akomantosoAddNamespaceXSLTPath));
                       
//apply to the result the XSLT that insert the namespace
 StreamSource resultWithNamespace = xsltTransformer.transform(result, ssAnXsltpath);
               

2) Object use :

I noticed that whenever you use the XPathResolver / XSLTTransformer / DocmentBuilderFactory clases you use getInstance() or newInstance() even if you are calling them on succesicve lines of code...

e.g. in the below you are creating a new XPathResolver object on every line... is there a reason for this ? why not creat the object once and call its methods successively ?

Node templateContent = (Node)XPathResolver.getInstance().evaluate(XSLTDoc, "//*:template[@match=\"*[@name='" + elementName + "']\"]/*", XPathConstants.NODE);
           
            //get the parent template of the xslt node
            Node parentTemplate = (Node)XPathResolver.getInstance().evaluate(pipeline, "//xslt[@href='" + xsltURI + "']/ancestor::*:template", XPathConstants.NODE);

            //remove the apply templates node
            if((Node)XPathResolver.getInstance().evaluate(pipeline, "//*:template[@match=\"*[@name='" + elementName + "']\"]/*:apply-templates",XPathConstants.NODE) != null)
            {
                //remove the apply templates node
                parentTemplate.removeChild((Node)XPathResolver.getInstance().evaluate(pipeline, "//*:template[@match=\"*[@name='" + elementName + "']\"]/*:apply-templates",XPathConstants.NODE));
            }




Luca Cervone

unread,
Jun 9, 2009, 12:08:01 PM6/9/09
to akomant...@googlegroups.com
Dear Ashok, 

1) Readabiltiy

I found some of the source code unreadable...

e.g.

  //apply the XSLT to the document
   StreamSource result = XSLTTransformer.getInstance().transform(new StreamSource(metalexFile), new StreamSource(xslt));
               
  //apply to the result the XSLT that insert the namespace
   StreamSource resultWithNamespace = XSLTTransformer.getInstance().transform(result, new StreamSource(new File(this.akomantosoAddNamespaceXSLTPath)));
               
I have made it more readable and easier to debug  :


Ok great. 



2) Object use :

I noticed that whenever you use the XPathResolver / XSLTTransformer / DocmentBuilderFactory clases you use getInstance() or newInstance() even if you are calling them on succesicve lines of code...

e.g. in the below you are creating a new XPathResolver object on every line... is there a reason for this ? why not creat the object once and call its methods successively ?

Node templateContent = (Node)XPathResolver.getInstance().evaluate(XSLTDoc, "//*:template[@match=\"*[@name='" + elementName + "']\"]/*", XPathConstants.NODE);
           
            //get the parent template of the xslt node
            Node parentTemplate = (Node)XPathResolver.getInstance().evaluate(pipeline, "//xslt[@href='" + xsltURI + "']/ancestor::*:template", XPathConstants.NODE);

            //remove the apply templates node
            if((Node)XPathResolver.getInstance().evaluate(pipeline, "//*:template[@match=\"*[@name='" + elementName + "']\"]/*:apply-templates",XPathConstants.NODE) != null)
            {
                //remove the apply templates node
                parentTemplate.removeChild((Node)XPathResolver.getInstance().evaluate(pipeline, "//*:template[@match=\"*[@name='" + elementName + "']\"]/*:apply-templates",XPathConstants.NODE));
            }


No Ashok, I'm not creating a new object  in each line. 
Here I use the Singleton pattern. The instance of the XPath resolver is always one. 
The Object XPATH resolver is a static object and is created only the first time that I call the getInstance method. 

Hope now is clearer. 

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:59:21 AM6/10/09
to akomant...@googlegroups.com


On Tue, Jun 9, 2009 at 7:08 PM, Luca Cervone <cervo...@gmail.com> wrote:
No Ashok, I'm not creating a new object  in each line. 
Here I use the Singleton pattern. The instance of the XPath resolver is always one. 
The Object XPATH resolver is a static object and is created only the first time that I call the getInstance method. 


Oh... alright ok. 

I also noticed that you have commented out  log4j logging in some places ... was there a reason for that ?

Ashok

Luca Cervone

unread,
Jun 10, 2009, 4:21:45 AM6/10/09
to akomant...@googlegroups.com
Hi ashok, 
I have commented the log4j lines because them raise a strange exception. 
I have noted to check this problem in my TODO list. 

Ciao
Luca

Flavio Zeni

unread,
Jun 10, 2009, 4:31:44 AM6/10/09
to akomant...@googlegroups.com
When all these items will end up in the DONE list!

Flavio


2009/6/10 Luca Cervone <cervo...@gmail.com>

Ashok Hariharan

unread,
Jun 10, 2009, 5:22:46 AM6/10/09
to akomant...@googlegroups.com


On Wed, Jun 10, 2009 at 11:21 AM, Luca Cervone <cervo...@gmail.com> wrote:
Hi ashok, 
I have commented the log4j lines because them raise a strange exception. 
I have noted to check this problem in my TODO list. 

the most common log4j problem can be resolved by setting the command line property ,  log4j.ignoreTCL=true

have you tried that ?

Ashok

Luca Cervone

unread,
Jun 10, 2009, 5:24:45 AM6/10/09
to akomant...@googlegroups.com
Thank you Ashok, I didn't try it. 
Let me see if it works for me. 

Ciao
Luca
Reply all
Reply to author
Forward
0 new messages