Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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.

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

Code:
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.
 
Old January 11th, 2010, 05:13 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

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?
 
Old January 12th, 2010, 06:15 AM
Authorized User
 
Join Date: Dec 2009
Posts: 23
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Hi Sam,Thanks for reply.

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

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

and in my xslt i have declared like this ..

Code:
<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)
 
Old January 12th, 2010, 06:26 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.