This generally makes more sense,
stuffing the <p> in the same namespace
Main Topics
Browse All TopicsHello. I have the following problem (described in XML comments).
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Well, you need to consider templates as some sort of rules.
If you push a certain node to the templates, the processor will check which rule fits best the description of the node
This "pushing" can be done using "apply-templates"
So, if I have this
<xsl:template match="page">
<xsl:apply-templates select="paragraph"/>
</xsl:template>
Then that means that all the child <paragraph> elements of <page> will be pushed to the templates
These nodes will be picked up by the template for "paragraph"
and the actions found in that template will be executed on these nodes
You can consider mode as an extra parameter for rule matching
if you say
<xsl:apply-templates mode="xhtml"/>
all children of the current context will be pushed to the templates,
but only the template rules with a mode="xhtml" will be evaluated
line by line
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.o
the stylesheet will start processing at the page element
<xsl:template match="page">
all paragraph children of the current context will be pushed to the templates ***
<xsl:apply-templates select="paragraph"/>
</xsl:template>
*** this template will pick up processing of the pushed paragraph node
<xsl:template match="paragraph">
create an element with no prefix but in the xhtml namespace
<xsl:element name="p" namespace="http://www.w3.o
push all text nodes and child nodes and all to the templates, but only evaluate the templates with the same mode +++
<xsl:apply-templates mode="xhtml"/>
</xsl:element>
</xsl:template>
+++ exectute this template with all the element childs of paragraph, but also with deeper nested constructs
<xsl:template match="*" mode="xhtml">
<xsl:element name="{local-name()}" namespace="http://www.w3.o
<xsl:copy-of select="@*"/>
push all text nodes and child nodes and all to the templates, but only evaluate the templates with the same mode +++
<xsl:apply-templates mode="xhtml"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Thanks for your solution. When I test it in Firefox, it works as expected. But when I try to run the transformation in NetBeans, it doesn't work. It generates this:
<html xmlns="http://www.w3.org/1
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test page</title>
</head>
<body>
<ns104:p
then it stops and throws an error:
Using com.sun.org.apache.xalan.i
javax.xml.transf
at com.sun.org.apache.xalan.i
at com.sun.org.apache.xalan.i
at com.sun.org.apache.xalan.i
I am posting my stylesheet and my input file.
I don't understand why it doesn't work in netbeans. There is a flaw in their namespace handling in the XSLT processor I am afraid.
Can you trace what the Processor is?
The behaviour in IE is normal if you installed an editor on the same machine which you indicated to be the default editor for XML. That is a problem with internet explorer. I avoid setting any editor as the default for XML in order to avoid this behaviour
This works as you would expact,
but the namespaces in XSLT and XML are not equal
xmlns:x="http://ondra.cifk
versus
xmlns:x="http://ondra.cifk
Business Accounts
Answer for Membership
by: GertonePosted on 2009-09-06 at 04:20:07ID: 25269459
This is what I think you need
Note also the use of templates instead of for-each.... it is a much better style of programming XSLT
Select allOpen in new window