• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I use java in XML file?

 
Lee Xu
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am curious to know. Thanks
 
Stanley Tan
Ranch Hand
Posts: 243
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean Java in XML? What would this accomplish?
Maybe you could have a Java application that writes the XML and then have another program parse it. Is that what you meant?
 
L Goundalkar
Ranch Hand
Posts: 395
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
you can use Java,( using CDATA) But for what?
Since XML is more like Structured Datastorage and the realted things like XSL, Xlink are used how to interact with the XML source and display the results or do some operation. So There is no tool (as for my knowledge) to execute an XML file.
I thik you can have Javascript codes in XML and you can execute them on Clinet side by extracting them using XSL.
If you find there is any other way to use Java than the one i have mentioned, please mail me.
Thanks.
------------------
L Goundalkar
lggoundalkar@hotmail.com
Sun Certified Programmer for Java 2 Platform
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
appologise for my ignorance if I'm completely off track, haven't had the luxury to do as much of this as I'd like but...
Doesn't XSLT allow some java code to assist transformations, XSLT is an XML-based language therefore XML has Java support?
Actually I think I'm wrong, from
XSTL -> Java support
it doesn't necessarily follow that
XML -> Java support
Summary: I think there's this XML based thing called XSLT that has Java included in some format and this might be where Lee Xu
is coming from.

Dave.
ps: thanks for the reminder once again that I need to get in and DO some of this stuff. Nag nag nag, can't a guy get any rest?
 
Lee Xu
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, All,
Thanks for your reply.
It means Java code can not appear in XML file, but can have places in XSL and CSS. Am I right?
 
L Goundalkar
Ranch Hand
Posts: 395
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
I still doubt if you can use Pure Java code in XSL.
Have you done it. If so then please send me the code.
I am really inetrested in this.
I think you can use Javascript but not Java.
Thanks.

------------------
L Goundalkar
lggoundalkar@hotmail.com
Sun Certified Programmer for Java 2 Platform
 
Kevin Yip
Ranch Hand
Posts: 110
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I doubt that the answer is no. XML is not a programming language. It's just a way to represent the hierarchy of data structure.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have inline-servlet code or jsp code inside the XSL( see Apache taglibs ) so that they get copied (as is) text to the output .html file. Checkout the taglib support in the Cocoon framework.
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
dexter ferreira
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you have java code in XML ? Yes you can
Can it do anything useful, being in the XML ? probably not. It will only be considered as data which the XML will store in the document.
You can use XSL and CSS to change the format of an XML document for displaying in a browser or any other application. It helps you modify/change the xml tree and add formatting and style elements to make the XML document suitable for display/inerpretation by programs/browsers.
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
You can use Java code inside XSL, or at least with Xalan (apache) you can without any problems (xalan extensions) you can also use Javascript, perl and python if you have IBM�s Bean Scripting Framework. What you cannot have is java(script) inside your XML to execute during transformation.
<example>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:js="ext1"
xmlns:metadados="ext2"
extension-element-prefixes="js metadados">
<xsl utput method="xml" indent="yes"/>
<lxslt:component prefix="metadados" elements="insert update delete">
<lxslt:script lang="javaclass" src="transform.MetadadosUpdater"/>
</lxslt:component>
<snip/>
<xsl:if test="METADADOS/@OP='D'">
<xsl:value-of select="metadados:delete($c_id, @R_ID)"/>
</xsl:if>
</example>
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic