This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 170917 - Failure to run script using <xslt> w/ Saxon
Summary: Failure to run script using <xslt> w/ Saxon
Status: RESOLVED WONTFIX
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on: 41689
Blocks:
  Show dependency tree
 
Reported: 2009-08-26 09:46 UTC by navneet
Modified: 2009-11-03 21:07 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample that recreates the bug (1.64 MB, application/x-compressed)
2009-09-04 14:37 UTC, navneet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description navneet 2009-08-26 09:46:34 UTC
I have an ant script from an existing project, so I tried creating a Free Form Java Application. I can run it from the
command line and it builds fine. When I try to build from within netbeans it gives me some errors related to xslt
transformation that is used in out ant script. I am assuming it has something to do with the xslt libraries that ship
with Netbeans. 

I can get around this problem if I can launch the ant target in a new process (like in fork). That way Netbeans'
libraries wont impact the ant script. I cant find a way to do this.
Comment 1 Peter Pis 2009-08-26 10:08:45 UTC
Reassigning to "java".
Comment 2 Jiri Prox 2009-08-26 10:29:46 UTC
Can you please provide error message and the related part of build script?
Comment 3 navneet 2009-08-26 10:37:01 UTC
This is part of the build.xml

This works fine on an ant instance outside Netbeans ( using ant 1.7.0 or 1.7.1 ), but not from within Netbeans.

---------
   <target name="genHbm" depends="checkMappingDependencies, compile-schema, copy-schemas"
           unless="hbmBuild.notRequired">
      <mkdir dir="${build.ddl}/tmp" />

      <ac:for list="${schemaFileList}" param="filename">
         <sequential>
            <echo message="-----------------------------" />
            <echo message="FILENAME = @{filename}" />

            <copy toFile="${build.ddl}/tmp/@{filename}.preexpand" file="${build.schema}/@{filename}.xml" />

            <switch value="@{filename}">
               <case value="core">
                  <expandNamespaces filename="@{filename}" expression="www.core." />
               </case>
               <case value="testSchema">
                  <expandNamespaces filename="@{filename}" expression="www.test." />
               </case>
               <case value="qaSchema">
                  <expandNamespaces filename="@{filename}" expression="www.qatest." />
               </case>
            </switch>

            <xslt style="${src.root}/schema/src/schemaToHbmPass1.xslt"
                  in="${build.ddl}/tmp/@{filename}.postexpand"
                  out="${build.ddl}/tmp/@{filename}.postxslt1"
                  classpathref="saxonpath"/>
         </sequential>
      </ac:for>

Comment 4 navneet 2009-08-26 12:20:17 UTC
Here is the error I see in the ant instance run through netbeans:

--
Processing /home/navneet/src-tree/try-ant/some-component/build/ddl/tmp/core.preexpand to
/home/navneet/src-tree/try-ant/some-component/build/ddl/tmp/core.postexpand
Loading stylesheet /home/navneet/src-tree/try-ant/some-component/schema/src/expandNamespaces.xslt
Processing /home/navneet/src-tree/try-ant/some-component/build/ddl/tmp/core.postexpand to
/home/navneet/src-tree/try-ant/some-component/build/ddl/tmp/core.postxslt1
Loading stylesheet /home/navneet/src-tree/try-ant/some-component/schema/src/schemaToHbmPass1.xslt
: Warning! file:/home/navneet/src-tree/try-ant/some-component/schema/src/schemaToHbmPass1.xslt: line 199: Attribute
'not-null' outside of element.
: Warning! file:/home/navneet/src-tree/try-ant/some-component/schema/src/schemaToHbmPass1.xslt: line 199: Attribute
'not-null' outside of element.
: Warning! file:/home/navneet/src-tree/try-ant/some-component/schema/src/schemaToHbmPass1.xslt: line 199: Attribute
'not-null' outside of element.
: Warning! file:/home/navneet/src-tree/try-ant/some-component/schema/src/schemaToHbmPass1.xslt: line 199: Attribute
'not-null' outside of element.
: Warning! file:/home/navneet/src-tree/try-ant/some-component/schema/src/schemaToHbmPass1.xslt: line 199: Attribute
'not-null' outside of element.
: Warning! file:/home/navneet/src-tree/try-ant/some-component/schema/src/schemaToHbmPass1.xslt: line 293: Attribute
'shortName' outside of element.
: Error! Error checking type of the expression 'funcall(tokenize, [variable-ref(translatedInput/string), literal-expr(,)])'.
: Fatal Error! Could not compile stylesheet
Failed to process /home/navneet/src-tree/try-ant/some-component/build/ddl/tmp/core.postexpand
Comment 5 navneet 2009-08-26 12:21:25 UTC
Removing the incomplete keyword since i've added the xml and the result from netbeans.
Comment 6 Milan Kubec 2009-08-26 20:47:27 UTC
Did you install any extensions to command line Ant? Or did you install any extensions to JDK itself?
Comment 7 Milan Kubec 2009-09-02 08:59:08 UTC
Setting INCOMPLETE again until there are some answers to questions in last comment.
Comment 8 navneet 2009-09-02 10:00:16 UTC
I did not install any extensions. I just set the ant location from the options dialog.
Comment 9 Milan Kubec 2009-09-02 11:13:54 UTC
I tried to reproduce your use case and it works for me. I've created simple freeform with build.xml just with xsl
transformation and changed Ant location in Tools | Options to external Ant and it still works for me. Doesn't your
script rely on something that is set via CLASSPATH system variable. What 'saxonpath' reference refers to? Doesn't seem
to be NetBeans problem rather some environment specific setting.
Comment 10 navneet 2009-09-02 11:15:42 UTC
If that is the case, why does running the same ant script from commandline using the same ant installation work ?
Comment 11 Milan Kubec 2009-09-02 12:58:33 UTC
Well, there probably is some issue with XML related libraries used by Ant when running inside IDE.

navneet, what contains your CLASSPATH system variable?

Jesse, do you have any idea how to override NetBeans XML related libraries for running freeform Ant script?
Comment 12 navneet 2009-09-02 13:59:34 UTC
I have nothing specific added on my machine. Whatever is used is for the build process and thats happening from within
the chain of ant files that are running for the build to complete.
Comment 13 Jesse Glick 2009-09-02 21:52:17 UTC
XML-related libraries are notoriously finicky in this regard. The way implementations are found in various class loaders
(by JAXP and to some extent by impls themselves) is complex, poorly standardized, and prone to all kinds of
environmental failures. Generally you get it working by trial and error.

Not a P2 since the XSLT processor could be run by forking a process. Most simply, launch the Ant main class with the
appropriate args and ${ant.core.lib} in CP.

INCOMPLETE until a complete, self-contained, reproducible test case is supplied.
Comment 14 navneet 2009-09-04 14:37:14 UTC
Created attachment 87115 [details]
Sample that recreates the bug
Comment 15 navneet 2009-09-04 14:39:36 UTC
Attaching a sample that works from the commandline on ant 1.7.1 but does not work from within Netbeans, even if Netbeans
has been configured to use the same ant installation.
Comment 16 Jesse Glick 2009-09-17 00:39:56 UTC
Will look at it when I have some time. Not an immediate priority since it's unlikely there's anything to be done about
on NB's side anyway.
Comment 17 Jesse Glick 2009-11-03 21:07:40 UTC
If you add

<factory name="net.sf.saxon.TransformerFactoryImpl"/>

(to override the Xalan-XSLTC transformer which is the default in the Sun JDK) and use a build of Ant 1.8.0, it works
fine from either the command line or NetBeans.

(There are various problems with class loading from bundled tasks in Ant 1.7.1 that will be fixed in 1.8.0.)