473,408 Members | 2,888 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,408 software developers and data experts.

Is it possible with XSLT????

How to transform:
<html>
<h1>Title</h1>
<h2>Header1</h2>
Content
<h3>Subeader1</h3>
Subcontent
</html>

to:
<newsletter>
<title>Title</title>
<section header="Header1">
Content
<subsection header="Subheader1">
Subcontent
</subsection>
</section>
</newsletter>

Any help appreciated!
Jul 20 '05 #1
1 1205
In article <ea**************************@posting.google.com >,
Luke Olek <ol******@go2.pl> wrote:

% How to transform:
% <html>
% <h1>Title</h1>
% <h2>Header1</h2>
% Content
% <h3>Subeader1</h3>
% Subcontent
% </html>

You need templates to match each of the tags you want to change.
Here's one for html:
<xsl:template match="html">
<newsletter>
<xsl:apply-templates>
</newsletter>
</xsl:template>

the one for title will be similar. For the section headers,
you can do essentially the same thing. To get a value into the
attribute, use an attribute value template:

<xsl:template match="h1">
<section header="{text()}">
<xsl:apply-templates>
</section>
</xsl:template>

to copy the content,

<xsl:template match="node()|@*">
<copy>
<xsl:apply-templates select="node()|@*">
</copy>
</xsl:template>

once you get to the lowest-level heading, you can fast-path the copy
by using <xsl:copy-of select="node()"/> instead of xsl:apply-templates.

--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #2

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

Similar topics

2
by: Ralf Wahner | last post by:
Dear Masters of XSLT Could I ask you for a clue on the following question? I'd like to use XSLT to transform an XML source file to LaTeX. In the following small example the <para> Element...
1
by: Matt | last post by:
Is it possible to put XSL instructions inside JavaScript? For example, pop up a message box with the xml value: alert(value in xml); Approach #1: <script type="text/javascript">...
4
by: titanandrews | last post by:
Hi, I have ran into a situation that I think should be possible, but I am fairly new to XSLT so maybe not. Suppose I have the following document <ROOT> <FOO name="A"> <CHILD name="B"/>...
6
by: Mark Miller | last post by:
I have a scheduled job that uses different XSL templates to transform XML and save it to disk. I am having problems with the code below. The problem shows up on both my development machine (Windows...
2
by: Richard L Rosenheim | last post by:
Is it possible to include addition tags in a XSLT file, that the XSLT processor will, for all practical purposes, ignore? What I'm looking to do is to include a section to contain information...
1
by: donjonnio via DotNetMonster.com | last post by:
Heres my problem: I am outputting XML from a dataset and using XSLT to format the output as HTML and the Response.ContentType = "application/vnd.ms-excel" directive to load the output as an...
6
by: blabla120 | last post by:
Hello, I have a source file with <StartEvent starttime="2006-04-19T20:15:00Z"/> I want to transform it with XSLT into <Starttime>2006-04-21T20:15:00Z</Starttime>
5
by: patrin | last post by:
Hi All, given the source document: <?xml version="1.0" encoding="UTF-8"?> <root> <child> <test id="1" name="first child"/> </child> <child>
4
by: Lord0 | last post by:
Hi there, Is the following possible with XSLT? Given the following example XML docs: <!-- doc 1--> <user> <username>myUsername</username> <password></password> <phone>12345</phone>
5
by: Simon Brooke | last post by:
This is supposed to be a very simple XSL stylesheet to strip styling information out of HTML documents - it could not be more basic. And yet, it doesn't work. I'm obviously getting something very...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.