Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old January 11th, 2010, 03:15 AM
Authorized User
Join Date: Dec 2009
Posts: 23
Thanks: 3
Thanked 0 Times in 0 Posts
Default Split xml file with result document and javax.xml.transform.Transformer.

hi all,

I have a XSLT which will split large xml file into multiple xml file with the use of following xslt code.

<xsl:variable name="filename" select="resolve-uri(concat('splitfilesfolder/',position(),'.xml'))" /> 
 <xsl:result-document href="{$filename}" format="xml">
    <--XML file content --->
then i have used that XSLT in my code to split input XML file using javax.xml.transform.Transformer.

TransformerFactory tFactory = TransformerFactory.newInstance();
Source xslSource =  new StreamSource(xsltfilepath);

Transformer trans = tFactory.newTransformer(xslSource);
trans.transform(new StreamSource(xmlFileName), new StreamResult(splitfilesfolder));
Here i want to give same path for new Streamresult as it is in result document path(i.e splitfilesfolder) .

Can we point same folder for result document href and new Streamresult argument ??

Can anybody please give me a solution ?

Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old January 11th, 2010, 05:13 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

Why not just pass in a parameter to the XSLT?

trans.setParameter("folderName", myFolder);

and then in the xslt:

<xsl:parameter name="folderName"/>

<xsl:variable name="filename" select="resolve-uri(concat($folderName, '/',position(),'.xml'))" />
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
Reply With Quote
  #3 (permalink)  
Old January 12th, 2010, 06:15 AM
Authorized User
Join Date: Dec 2009
Posts: 23
Thanks: 3
Thanked 0 Times in 0 Posts

Hi Sam,Thanks for reply.

I have declared my directory path.
String  myFolderName = "c:/myfolder";
and then i have set parameter like this

trans.setParameter("dir", myFolderName);
trans.transform(new StreamSource(xmlFileName), new StreamResult(myFolderName));

and in my xslt i have declared like this ..

<xsl:param name="dir"/>  
<xsl:variable name="filename" select="resolve-uri(concat($dir,'/',position(),'.xml'))" />

i got below exception when i perform

trans.transform(new StreamSource(xmlFileName), new StreamResult(myFolderName));

i dont know what the problem is .

Can anybody help ?

=================== Exception ================

java.lang.NoClassDefFoundError: oracle/i18n/text/OraCollator
at oracle.xml.xqxp.functions.builtIns.FNUtil.getColla tor(FNUtil.java:329)
at oracle.xml.xqxp.datamodel.OXMLItem.compareValue(OX MLItem.java:898)
at oracle.xml.xpath.XPathItem.compareValue(XPathItem. java:372)
at oracle.xml.xpath.XPathSequence.compareGeneral(XPat hSequence.java:1253)
at oracle.xml.xpath.ComparisonExpr.evaluate(XSLExpr.j ava:1505)
at oracle.xml.xpath.XPathPredicate.filter(XPathPredic ate.java:197)
at oracle.xml.xpath.XSLExprBase.filterPredicates(XSLE xprBase.java:415)
at oracle.xml.xpath.XPathVarReference.evaluate(XPathV arReference.java:145)
at oracle.xml.xslt.XSLForEach.processAction(XSLForEac h.java:124)
at oracle.xml.xslt.XSLNode.processChildren(XSLNode.ja va:480)
at oracle.xml.xslt.XSLTemplate.processAction(XSLTempl ate.java:205)
at oracle.xml.xslt.XSLStylesheet.execute(XSLStyleshee t.java:580)
at oracle.xml.xslt.XSLProcessor.processXSL(XSLProcess or.java:313)
at oracle.xml.jaxp.JXTransformer.transform(JXTransfor mer.java:381)
at com.celtic.ccview.dao.db2sp.ConvertXMLtoDatabaseDb 2sp.insertXMLdataIntoTable(ConvertXMLtoDatabaseDb2 sp.java:68)
at com.celtic.ccview.service.impl.T0020andT0026Import ServiceImpl.validateAndUpdateXMLFileData(T0020andT 0026ImportServiceImpl.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:182)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :149)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:106)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :171)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy7.validateAndUpdateXMLFileData(Unknown Source)
at com.celtic.ccview.service.T0020andT0026ImportServi ceTest.testValidateAndUpdateXMLFileData(T0020andT0 026ImportServiceTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.internal.runners.TestMethod.invoke(TestM ethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMet hod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(Meth odRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBefores ThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(Me thodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(Method Roadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invok eTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMe thods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run (JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotec ted(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtecte d(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(J Unit4ClassRunner.java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
Reply With Quote
  #4 (permalink)  
Old January 12th, 2010, 06:26 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts

That's failed very deep inside the Oracle XSLT processor so I think you'll have to ask Oracle for help.

Note that the Oracle XSLT 2.0 processor is a partial implementation which, as far as I know, has not been actively developed for some years.
Michael Kay
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
transform csv file to xml David Li XSLT 8 December 11th, 2012 04:57 AM
<?javax.xml.transform.disable-output-escaping ?> robbert XSLT 5 January 5th, 2011 07:28 PM
javax.xml.transform.TransformerConfigurationExcept ashok.andena XSLT 9 March 7th, 2008 08:14 AM
Exception in thread "main" javax.xml.transform.Tra XSLTUser XSLT 1 December 29th, 2007 04:59 AM

All times are GMT -4. The time now is 03:39 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.