473,326 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

need help from xsl guru

Hi,
I write an xml file structure and I would like to write an xsl file for it.
Can someone give me some help??
thank you.

Eric

<parents>

<parent>
<name> p1 </name>
<id>1000</id>

<child>
<name> c1 </name>
<id>1001</id>
</child>

<child>
<name> c2 </name>
<id>1002</id>
</child>
</parent>
<parent>
<name> p2 </name>
<id>2000</id>

<child>
<name> c3 </name>
<id>2001</id>
</child>
</parent>

<parent>
<name> p3 </name>
<id>3000</id>
</parent>

</parents>
Jul 20 '05 #1
6 1711
> I write an xml file structure and I would like to write an xsl file
for it.
Can someone give me some help??


An XSL to do what? format? transform? sort? filter?

Try http://www.altova.com they have GUI based WYSIWYM (What You See Is
What You Mean) editors that can help you create XSLTs
In Peace,
Saqib Ali
http://validate.sf.net

Jul 20 '05 #2
I would like to simply show a html which indicates the parents and
children relationship for each parent in my xml.

Eric

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
> I would like to simply show a html which indicates the parents and
children relationship for each parent in my xml.


Hi,

Perhaps you are looking for something like this:

<?xml version="1.0" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="html" indent="yes"/>

<xsl:template match="parents">
<html>
<head/>
<body>
<ul>
<xsl:apply-templates mode="2html"/>
</ul>
</body>
</html>
</xsl:template>

<xsl:template match="*" mode="2html">
<li>
<span style="color:blue"><xsl:value-of select="local-name()"/></span>
<ul>
<xsl:apply-templates select="node()" mode="2html"/>
</ul>
</li>
</xsl:template>
</xsl:stylesheet>

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #4
Hi,Joris:

I checked the html output. it is still a little bit different than I thought.

How can we have something like:

p1 1000
c1 1001
c2 1002
p2 2000
c3 2001
p3 3000
thanks.

Eric
"Joris Gillis" <ro**@pandora.be> wrote in message news:<op**************@news.pandora.be>...
I would like to simply show a html which indicates the parents and
children relationship for each parent in my xml.


Hi,

Perhaps you are looking for something like this:

<?xml version="1.0" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="html" indent="yes"/>

<xsl:template match="parents">
<html>
<head/>
<body>
<ul>
<xsl:apply-templates mode="2html"/>
</ul>
</body>
</html>
</xsl:template>

<xsl:template match="*" mode="2html">
<li>
<span style="color:blue"><xsl:value-of select="local-name()"/></span>
<ul>
<xsl:apply-templates select="node()" mode="2html"/>
</ul>
</li>
</xsl:template>
</xsl:stylesheet>

regards,

Jul 20 '05 #5
> How can we have something like:

p1 1000
c1 1001
c2 1002
p2 2000
c3 2001
p3 3000


here you go:

<?xml version="1.0" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="html" indent="yes"/>

<xsl:template match="parents">
<html>
<head>
<style type="text/css">
p {margin:0px}
</style>
</head>
<body>
<xsl:apply-templates mode="2html"/>
</body>
</html>
</xsl:template>

<xsl:template match="*" mode="2html">
<p style="padding-left:{count(ancestor::*)}em"><xsl:value-of select="name"/> <xsl:value-of select="id"/></p>
<xsl:apply-templates select="child" mode="2html"/>
</xsl:template>
</xsl:stylesheet>

regards,

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #6
eric <ez***@shaw.ca> wrote:
Hi,Joris:

I checked the html output. it is still a little bit different than I thought.

How can we have something like:

p1 1000
c1 1001
c2 1002
p2 2000
c3 2001
p3 3000

If you can compile a Bash shell, then you can try

start () {
case ${XML_ELEMENT_STACK[1]} in
child) [ "$parent_name" ] && printf '%s %s\n' $parent_{name,id}
unset parent_{name,id}
;;
esac
}
data () {
local e=${XML_ELEMENT_STACK[1]}
case $e in
name|id)
pp_append ${XML_ELEMENT_STACK[*]|/^(child|parent)$}
strcpy $2_$e $1
;;
esac
}
end () {
case ${XML_ELEMENT_STACK[1]} in
parent) printf '%s %s\n' $parent_{name,id}
child) printf '\t%s %s\n' $child_{name,id}
esac
}
xml -s start -d data -e end "`< file.xml`"

Ref:
http://freshmeat.net/projects/bashdiff/

--
William Park <op**********@yahoo.ca>
Open Geometry Consulting, Toronto, Canada
Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rmn | last post by:
Hi, I'm looking for the translation betwen the color spaces, but I must be mistaken with the methods to use, losing the values. Please, I need a little help of a "coloured guru"....
1
by: Jarrod Hyder | last post by:
Ok, I wrote my own weblog and I'm working on the web interface for adding/editing my posts. I decided to add a little preview button...when the button is clicked it is suppose to open a pop-up...
5
by: trint | last post by:
The WritePrinter() is working. I know this ReadPrinter() implementation isn't correct because it never reads into "reaDstrinG" buffer from the printer...But, I'm sure one of you Guru's do know how...
6
by: trint | last post by:
The WritePrinter() is working. I know this ReadPrinter() implementation isn't correct because it never reads into "reaDstrinG" buffer from the printer...But, I'm sure one of you Guru's do know how...
4
by: Tim::.. | last post by:
I have asked this question several times and can't seem to get the answer I am looking for! I am trying to create a form that responds dynamically to the users choises within the page. At the...
16
by: Singulus | last post by:
Hello all, I've searched for similar threads, I've found some bit of useful info here and there, but nevertheless I want to post my questions...So, how can I (we, in fact the forum can benefit...
6
by: squishy | last post by:
I tried to hire programmers to do some stuff, but cannot find reliable, intelligent C++ Gurus (at Guru or RentACoder at least). So I am stuck learning C++ and doing the jobs myself. I would...
6
by: Steven W. Orr | last post by:
Given the following code: (I hope it's as simple as possible) :-) #! /usr/bin/python import new class BASE: def __init__( self ): print 'Hello from BASE init' def m1( self ): print 'M1 Base:...
2
by: Dotan Cohen | last post by:
I need an application, and I'd like it to be written in Python with QT as I am a KDE user. I simply don't have the time to code it myself, as I've been trying to find the time for half a year now....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.