Hi,
I'm creating a system where my XML includes HTML tags (<h1></h1>) in addition to other XML elements (<book></book>).
I would like to render the HTML tags back to HTML using XSL. Considering I want to replace all headings, I could do for each heading level (i.e. repeat the following code for h2, h3, h4, h5, etc.):
<xsl:template match="h1">
<h1><xsl:appl y-templates/></h1>
</xsl:template>
or I can just write once:
<xsl:template match="*[starts-with(local-name(), 'h')]">
<xsl:copy><xsl: apply-templates/></xsl:copy>
</xsl:template>
The problem is that with xsl:copy, I'm loosing the 'native' HTML appearance of the tags. For example, the headings will be displayed inline rather than block. To solve this I can just edit the stylesheet and add display:block to all headings - meaning I'm doing extra job anyway, but I was wondering if there is any smart way of doing this.
Ideally, I would like to do something like this:
<xsl:template match="p|ul|li| dl|dt|dd|i|em|s trong|b">
<xsl:copy><xsl: apply-templates/></xsl:copy>
</xsl:template>
rather than writing each separately.
Thanks in advance,
Izhaki
1 1700 jkmyoung 2,057
Recognized Expert Top Contributor
Are you missing copying the attributes?
Guessing something like: -
<xsl:template match="h1|h2|h3|h4|h5">
-
<h1>
-
<xsl:copy-of select="@*"/>
-
<xsl:apply-templates/>
-
</h1>
-
</xsl:template>
-
<xsl:template match="*">
-
<xsl:copy>
-
<xsl:copy-of select="@*"/>
-
<xsl:apply-templates/>
-
</xsl:copy>
-
</xsl:template>
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mel |
last post by:
Are we going backwards ? (please excuse my spelling...)
In my opinion an absolute YES !
Take a look at what we are doing ! we create TAGS, things like <H1> etc.
and although there are tools (dreamweaver and the like), they are all at the
lowest level of programming (something like assembly as oposed to C++ etc.).
These tools create "brain-dead" developers that constantly have to plough
through tons of tags to do the simplest thing.
...
|
by: Howard Kaikow |
last post by:
Where is the official documentation of what constitutes a minimally
compliant HTML file?
--
http://www.standards.com/; See Howard Kaikow's web site.
|
by: mike |
last post by:
regards:
I follow the following steps to converting from HTML to XHTML
http://webpageworkshop.co.uk/main/xhtml_converting
My parser is http://htmlparser.sourceforge.net/
Xhtml version is 1.0 from http://nds.nokia.com/uaprof/N6600r100.xml
but nokia mobile browser cannot identify the converted file(XHTML1.0).
Is there something wrong with my procedure.
|
by: prabha |
last post by:
Hello Everybody,
I have to conert the word doc to multiple html files,according to the templates in the word doc.
I had converted the word to xml.Also through Exsl ,had finished the multiple output html files.
The problem is while reading through the worddoc paragraph,the special characters are not identified.
So in the xml file,it's just storing that as "?".So I couldn't able to retrive the characters in my ouput html files.
|
by: Charles Law |
last post by:
Does anyone have a regex pattern to parse HTML from a stream?
I have a well structured file, where each line is of the form
<sometag someattribute='attr'>text</sometag>
for example
<SPAN CLASS='myclass'>A bit of text</SPAN>, or
Just some text, without tags
| |
by: Eric Lindsay |
last post by:
I have been trying to get a better understanding of simple HTML, but I
am finding conflicting information is very common. Not only that, even
in what seemed elementary and without any possibility of getting wrong
it seems I am on very shaky ground .
For example, pretty much every book and web course on html that I have
read tells me I must include <html>, <head> and <body> tag pairs.
I have always done that, and never questioned it. ...
|
by: sysxperts |
last post by:
Hi,
I have a mail server that generates archives in a directory for every
message sent or received and each archive has an associated XML file
with <sender>, <receiver>, <subject> and other email related tags and
all files have same exact format. I would like to generate reports in
a web page based upon the content of these XML files but not sure where
to start. I know how to make an individual XML file display in browser
by linking a...
|
by: anupamjain |
last post by:
Hi,
After 2 weeks of search/hit-and-trial I finally thought to revert to
the group to find solution to my problem.(something I should have done
much earlier)
This is the deal :
On a JSP page, I want to grab a URL and parse /change the HTML and send
it to the JSP page. I take the URL from the user in a textbox (not the
|
by: since |
last post by:
I figured I would post my solution to the following.
Resizable column tables.
Search and replace values in a table. (IE only)
Scrollable tables.
Sortable tables.
It is based on a lot examples I found on the web. Works in IE and mozilla.
http://www.imaputz.com/cssStuff/bigFourVersion.html
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |