Subject: RE: [xsl] Measure the length of an XML document in bytes From: "Khorasani, Houman" <houman_khorasani@xxxxxxxxxxxxxx> Date: Fri, 5 Aug 2005 15:29:06 +0100 |
Cheers! Finally it's working. How could I overlook the package folder? :) Thank you guys so much for your help. I have just one last question to this topic: <xsl:stylesheet version="1.0" xmlns:my-class="xalan://ELSPackage.XMLGetFileSize" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" Having the my-class namespace in the style sheet; it appends the namespace to every created XML tag. e.g.: <xsl:element name="OrderRequest"> Becomes in the output: <OrderRequest xmlns:my-class="xalan://ELSPackage.XMLGetFileSize"> How do I prevent that each XML tag retrieves this namespace? I tried to solve it in this way, but it doesn't work: <xsl:stylesheet version="1.0" xmlns:my-class="xalan://ELSPackage.XMLGetFileSize" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="OrderRequest"> Any idea? Thanks Houman -----Original Message----- From: George Cristian Bina [mailto:george@xxxxxxx] Sent: 05 August 2005 12:30 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Measure the length of an XML document in bytes Hi, I think you should place the folder that contains the class in the classpath, not the class itself. Try replacing C:\Header\Utility.class with C:\Header\. >>>package MyPackage; Also the code suggests that the Utility class is inside a package, so you will need to create a MyPackage folder in C:\Header and place the class there. Regards, George --------------------------------------------------------------------- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com Mukul Gandhi wrote: > Surprising it works on my PC. I suggest, please remove xml-apis.jar > and xercesImpl.jar from CLASSPATH. Please just include xalan.jar. > > Regards, > Mukul > > On 8/5/05, Khorasani, Houman <houman_khorasani@xxxxxxxxxxxxxx> wrote: > >>Excellent!!! >> >>There is only one problem. Both XMLSpy and Xalan are showing the same >>error: >> >> File Size : >>(Location of error unknown)XSLT Error >>(javax.xml.transform.TransformerException) : >>java.lang.NoSuchMethodException: For extension function, could not find >>method java.lang.String.getFileSize([ExpressionContext,] ). >> >> >>It produces the text "File Size :" but then the method fails. It can't >>be located. >> >>I have the following jars in my classpath: >> >>C:\xalan-j_2_6_0\bin\xalan.jar;C:\xalan-j_2_6_0\bin\xml-apis.jar;C:\xe rc >>es-2_7_1\xercesImpl.jar;C:\Header\Utility.class >> >>I have no idea why it doesn't find the method within the class. Any >>idea? >> >>Many thanks, >>Houman >> >> >>-----Original Message----- >>From: Mukul Gandhi [mailto:gandhi.mukul@xxxxxxxxx] >>Sent: 05 August 2005 12:05 >>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx >>Subject: Re: [xsl] Measure the length of an XML document in bytes >> >>You can configure Xalan-J in XMLSpy 2005 EE as follows: >> >>In Tools | Options | XSL >> >>Specify in "External Transformation Program" >>java org.apache.xalan.xslt.Process -in %1 -xsl %3 -out %2 -param >>filename node.xml >> >>Xalan-J's JAR file should be in JVM's CLASSPATH. >> >>(The namespace of Java class need not be changed) >> >>Regards, >>Mukul >> >>On 8/5/05, Khorasani, Houman <houman_khorasani@xxxxxxxxxxxxxx> wrote: >> >>>Hello Mukul, >>> >>>Very nice example. Indeed I could try to convince the project manager >>>with this solution. >>> >>>However we are right now using just the built-in XSLT processor of >>>XMLSpy 2004. And I have to present them the demo with that. >>> >>>What do I have to do in order to use the class with XMLSpy? I guess >> >>the >> >>>namespace below has to be changed, right? >>> >>>xmlns:my-class="xalan://MyPackage.Utility" >>>... >>>File Size : <xsl:value-of select="my-class:getFileSize($filename)" /> >>>bytes >>> >>> >>>Many Thanks, >>>Houman >>> >>> >>>-----Original Message----- >>>From: Mukul Gandhi [mailto:gandhi.mukul@xxxxxxxxx] >>>Sent: 05 August 2005 05:13 >>>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx >>>Subject: Re: [xsl] Measure the length of an XML document in bytes >>> >>>Hi Houman, >>> I just finished writing a Java extension function which determines >>>file size in bytes (as reported by Windows). Below is the Java code, >>>XSLT stylesheet and Xalan command line. With this stylesheet, we can >>>pass the file name from command line. >>> >>>Java file >>>----------- >>>package MyPackage; >>> >>>import java.io.File; >>> >>>public class Utility { >>> >>> public static long getFileSize(String filename) { >>> File file = new File(filename); >>> return file.length(); >>> } >>>} >>> >>>XSLT stylesheet >>>----------------------- >>><?xml version="1.0" encoding="UTF-8"?> >>><xsl:stylesheet version="1.0" >>> xmlns:my-class="xalan://MyPackage.Utility" >>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> >>> >>><xsl:output method="text" /> >>> >>><xsl:param name="filename" /> >>> >>><xsl:template match="/"> >>> File Size : <xsl:value-of select="my-class:getFileSize($filename)" /> >>>bytes >>></xsl:template> >>> >>></xsl:stylesheet> >>> >>>Xalan Command Line >>>------------------------------ >>>C:\xml\xsleg\xslt>java org.apache.xalan.xslt.Process -in file_size.xsl >>>-xsl file >>>_size.xsl -PARAM filename node.xml >>> >>> File Size : 111 bytes >>> >>>But sorry, if this is not what you want. Just thought of sharing the >>>code. >>> >>>Regards, >>>Mukul >>> >>>On 8/4/05, Khorasani, Houman <houman_khorasani@xxxxxxxxxxxxxx> wrote: >>> >>>>Hi Mukul, >>>> >>>>Interesting idea. However I am stuck between two middlewares. I >> >>have >> >>>to >>> >>>>use plain XSLT's. There won't be any java involved. >>>> >>>>Actually, I read the customers req. and it says lengths of the >>>>characters are good enough. So I don't need to know the length in >>> >>>bytes. >>> >>>>So if I would use string-length() like this >>>> >>>><xsl:value-of select="string-length(*)"/> >>>> >>>>I would get just the length of the first value. >>>>I wish I could use it like that: >>>> >>>><xsl:value-of select="string-length(<xsl:copy-of select="*"/>)"/> >>>> >>>>But this is not possible. >>>>Any ideas how to count the length of a document character by >>> >>>character? >>> >>>>Many thanks, >>>>Houman
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Measure the length of an , Khorasani, Houman | Thread | RE: [xsl] Measure the length of an , Mauritz Jeanson |
[xsl] XML parser discussion forum q, Rahil | Date | Re: [xsl] XML parser discussion for, Mulberry Technologie |
Month |