473,387 Members | 1,464 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,387 software developers and data experts.

help with xlst .. only extract parts

Hi, I hope this is a proper place to post :)

This is my XML file:

<?xml version="1.0" encoding="utf-8"?>
<foo>
<address>a lot of tags and text</address>
<hubid>a lot of tags and text</hubid>
<thestamps>
<stamp name="A1">bla</stamp>
<stamp name="A2">foo</stamp>
<stamp name="A3">muh</stamp>
<sub type="1">
<stamp name="B1">aaa</stamp>
<stamp name="B2">bbb</stamp>
<stamp name="B3">ccc</stamp>
</sub>
</thestamps>
</foo>

I have to extract all elements with tag name STAMP in that form
(without the ---- doc... ----):
---- document begin ----
A1 ... bla
A2 ... foo
A3 ... muh
B1 ... aaa
B2 ... bbb
B3 ... ccc

---- document end ----

this would be my XsL file

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:output method="html"/>
<xsl:template match="address"></xsl:template>
<xsl:template match="hubid"></xsl:template>
<xsl:template match="stamp[@name]">
<xsl:value-of select="@name"/>
<xsl:text... </xsl:text>
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>

I dont think this is very elegant and might be errorprone .. can you
do this better?

thank you so much

Petra

Jun 21 '07 #1
1 1787
I dont think this is very elegant and might be errorprone .. can you
do this better?
Yes. What you've got now won't come close to working.

.... Oh, you want us to tell you *how* to do it better? Set up a root
template, and from there use <xsl:apply-templateswith a select that
specifically requests processing of your <stamp>s. Then you only need a
template for stamp, and you're done.

Understanding why what you posted doesn't work, and how to apply the
above hint, is left as an exercise for the student. A good XSLT tutorial
will answer those questions and more; herewith, my standard pointer to
http://www.ibm.com/xml for many tutorials and articles about XML processing.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jun 21 '07 #2

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

Similar topics

3
by: Hai Nguyen | last post by:
I would like to know after transforming my datatables which store in dataset into XML form. Now I want to save it into a file and also create a XLST file to read it. How can I do that? Would you...
3
by: deko | last post by:
I'm sure someone has passed this way before... I want to check to see is a domain name is contained in a string, and if one is, I want to extract it. In these strings, domains are always...
9
by: flit | last post by:
Hello All, Using poplib in python I can extract only the headers using the .top, there is a way to extract only the message text without the headers? like remove the fields below: "...
1
by: sarah12 | last post by:
HI, This time , I need to write the XSL to transform the following document : <?xml version="1.0"?> <nplbiblio rundate="20080110"> <document status="U" creadate="19990410">...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.