wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Colon inside tag and xsl referring two xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Colon inside tag and xsl referring two xml" Watch "Colon inside tag and xsl referring two xml" New topic
Author

Colon inside tag and xsl referring two xml

shailendra vasale
Ranch Hand

Joined: Dec 17, 2000
Posts: 38
hi All,
I am facing two problems.Can anyone help me out.
1. I'm generating a xml file using DOM Object reading contents from my database.Now I want to insert a tag <xsp : page> in my .xml file when it gets created.So when I use
" set rootElement=domObj.CreateNode("Element","xsp : page","")
domObj.appendchild(rootElement) "
The server throws error.
I even tried doing it using ISO-Latin-1 Character Set[:] but couldn't succeed.Can you help me out.
2. I want to refer two different xml files in my single xsl,how can I do this?.Using External Entities it is possible to make a single xml document of two different files and can apply xsl to that but what I want to do is - I want to take the data from two diff xml files,do calculation and show the result,using single xsl.How can I do this?
Thanks in advance.
Regards,
SHAILENDRA.
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
question 2. To read the second XML document you can use document('filename.xml') function


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
shailendra vasale
Ranch Hand

Joined: Dec 17, 2000
Posts: 38
hi Mapraputa Is,
Thanks for your reply.Well! I merged two xml files using document('filename.xml').It works fine with following examples.But don't the same o/p on inserting cocoon pi and xsp declaration.
margin.xml
----------
<?xml version="1.0" encoding="UTF-8"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="merge.xsl" type="text/xsl"?>
<margin>
<margin1>5</margin1>
<margin2>10</margin2>
</margin>

style.xml
---------
<?xml version="1.0" encoding="UTF-8"?>
<?cocoon-process type="xslt"?>
<style>
<style1>
<cost>100</cost>
</style1>
<style2>
<cost>200</cost>
</style2>
</style>

merge.xsl
---------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="xml"/>
<!--load the merge file -->
<xsl:variable name="sty" select="document(
'style.xml')"/>
<!-- combine the files -->
<xsl:template match="/">
<style1>
<!-- select all the child nodes of the margin tag in
the main file -->
<xsl:for-each select="margin/child::*">
<!-- copy the margin tag -->
<xsl:copy-of select="."/>
</xsl:for-each>
<!-- and all the child nodes of the style tag in the
merge file -->
<xsl:for-each select="$sty/style/child::*">
<!-- copy the style tag -->
<xsl:copy-of select="."/>
</xsl:for-each>
</style1>
</xsl:template>
</xsl:stylesheet>
-------------------------
O/P : 5 10 100 200
-------------------------
But when I insert the cocoon pi and xsp namespace declaration in both of my xml files then the o/p is only from margin.xml file.
eg the changes made in my magin.xml files are -
margin.xml
----------
<?xml version="1.0" encoding="UTF-8"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<xsp : page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
<?xml-stylesheet href="merge.xsl" type="text/xsl"?>
<margin>
<margin1>5</margin1>
<margin2>10</margin2>
</margin>
</xsp : page>

-------------------------
O/P : 5 10
-------------------------

What changes r required to make in my merge.xsl file.
Thanks in advance.
Regards,
SHAILENDRA.

[This message has been edited by shailendra vasale (edited August 08, 2001).]
shailendra vasale
Ranch Hand

Joined: Dec 17, 2000
Posts: 38
hi,
I got the desired o/p by making changes in my merge.xsl as -
" //.....
<xsl:for-each select="$sty/xsp : page/style/child::*">
//..... "

But can anyone help me for my Question 1? I'm still stuck to that.
Thanks.
Regards,
SHAILENDRA.
 
 
subject: Colon inside tag and xsl referring two xml
 
Similar Threads
Need help with JavaScript and JSF
How to run XSP? Urgent!!!!
Using xsl:choose in Cocoon
some notes on xml
XSL Include validation in Rational Application Developer 6.0