Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Colon inside tag and xsl referring two xml

 
shailendra vasale
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
question 2. To read the second XML document you can use document('filename.xml') function
 
shailendra vasale
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic