simple identity transform - what am I missing?
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 2
- Joined: Fri Feb 13, 2009 7:27 am
simple identity transform - what am I missing?
Post by stevedonie »
I must be missing something simple. Using this input:
and this stylesheet:
I am not seeing what I expect, which is that the div gets a description added before it. Am I missing something? Seems like the second template never matches.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simple</title>
<link rel="stylesheet" type="text/css" media="screen,print" href="style.css" />
</head>
<body>
<div style="text-align: center; ">
<p>
<a href="Next.html">
Next >
</a>
</p>
</div>
</body>
</html>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:preserve-space elements="*"/>
<xsl:output omit-xml-declaration="no" encoding="UTF-8"
doctype-public="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="div">
<description>n/a</description>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
-
- Posts: 2
- Joined: Fri Feb 13, 2009 7:27 am
Re: simple identity transform - what am I missing?
Post by stevedonie »
I think I found it! I was transforming XHTML, and apparently that is special - found what I needed here:
http://www.xmlplease.com/xhtmlxhtml
Argh!
http://www.xmlplease.com/xhtmlxhtml
Argh!
-
- Site Admin
- Posts: 2097
- Joined: Thu Jan 09, 2003 2:58 pm
Re: simple identity transform - what am I missing?
The problem is that your template matches div from no namespace while your document contains div in the http://www.w3.org/1999/xhtml namespace. The simplest way, as you use XSLT 2.0, is to declare the default XPath namespace adding xpath-default-namespace="http://www.w3.org/1999/xhtml" on the stylesheet
Best Regards,
George
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xpath-default-namespace="http://www.w3.org/1999/xhtml">
...
George
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service