XSLT iterating over dynamically generated XML.
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 3
- Joined: Wed Feb 07, 2007 7:22 am
XSLT iterating over dynamically generated XML.
Hi all,
I am trying to iterate over an xml document that does not have a defnite structure, it is generated dynamically and the name of the nodes are not at the same level always. I need to generate a collapsable and expandable structure at every level of the nodes.
I request you to please throw some light on this. I have been trying to do things but its not working out. If I am able to display just the immediate child nodes(not all child nodes) of a particular node I may be able to get some headway.
I have tried google but it hasn't helped. I am not really used to asking these type of questions(silly if it may sound), please help me.
Thanks a lot,
Amnesiac.
I am trying to iterate over an xml document that does not have a defnite structure, it is generated dynamically and the name of the nodes are not at the same level always. I need to generate a collapsable and expandable structure at every level of the nodes.
I request you to please throw some light on this. I have been trying to do things but its not working out. If I am able to display just the immediate child nodes(not all child nodes) of a particular node I may be able to get some headway.
I have tried google but it hasn't helped. I am not really used to asking these type of questions(silly if it may sound), please help me.
Thanks a lot,
Amnesiac.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
Your problem is too general. Without some sample files of the input XML and the expected result I think there are not many chances of receiving help. What did you try already, what is the current form of your stylesheet and what does not work in your stylesheet?
Regards,
Sorin
Your problem is too general. Without some sample files of the input XML and the expected result I think there are not many chances of receiving help. What did you try already, what is the current form of your stylesheet and what does not work in your stylesheet?
Regards,
Sorin
-
- Posts: 3
- Joined: Wed Feb 07, 2007 7:22 am
Thank you for the reply.
Sample XML FIle:
I want to display this xml file as a expandable and collapsable structure in an HTML page. I am using DIV tags for expanding and collapsing. The xml file could have anything except for the first root element 'Log'.
This is my XSL file:
The problem is when I click on the Href it tries to access a DIV tag which is not there. I am trying a way to eliminate the JS function call from Href and place in some static thing there. Basically I am trying to tie a particular href to a particular DIV tag. If you copy these files and double click on the .xml file you will understand.
Thanks a lot for the reply,
Amesiac.
Sample XML FIle:
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Trial.xsl"?>
<Log>
<Request>frequest()<fRequest>
<data>1</data>
<data>2</data>
<data>3</data>
</fRequest>
</Request>
<ARequest>aReq
</ARequest>
<BRequest>bReq
</BRequest>
</Log>
This is my XSL file:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/Log">
<html>
<body>
<h2> Log Details </h2>
<table border="1">
<tr><th>Node-set></th> <th>Value</th></tr>
<script language="JavaScript">
var idGen =0;
var evenTrack =0;
function expandIt(whichEl) {
whichEl.style.display = (whichEl.style.display == "none" ) ? "" : "none";
}
function generateNextID(){
return idGen++;
}
function getGenID(){
return idGen;
}
</script>
<xsl:call-template name="showChildren" />
</table>
</body>
</html>
</xsl:template>
<xsl:template name="showChildren" >
<xsl:param name="mat" select="Log"/>
<a href="javascript:expandIt(generateNextID())" ><xsl:value-of select="name(.)" /></a>
<div id="javascript:getGenID()" style="display:all">
<table border="1">
<xsl:for-each select="child::node()">
<tr>
<td> <xsl:call-template name="showChildren" /> </td>
<td><xsl:value-of select="text()"/></td>
</tr>
</xsl:for-each>
</table>
</div>
</xsl:template>
</xsl:stylesheet>
Thanks a lot for the reply,
Amesiac.
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service