span tags in html to html conversion
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 4
- Joined: Tue Nov 08, 2011 12:23 am
span tags in html to html conversion
Hello,
I can't figure out how to do this. I have an html generated from a document that I need to transform to another html doc. Everything is working great except when it comes to <span> tags inside of <p> tags. I need to transform:
into this
Also I am using xsl:choose and xsl:when for all <p> tags.
my transform snippet looks like this:
and
Any ideas?
I can't figure out how to do this. I have an html generated from a document that I need to transform to another html doc. Everything is working great except when it comes to <span> tags inside of <p> tags. I need to transform:
Code: Select all
<p><span class="x-first-para">Think that new opportunities, advancement within your own organization, and a bigger number for your next comp package are in your future? Not so fast.</span> Though you may be confident of your skills and past performance, you may be the only one. Be warned: In this rocky economic landscape, those responsible for assessing and valuing C-suite talent are assessing candidates with fresh eyes.</p>
Code: Select all
<p><span class="article_runin">Think that new opportunities, advancement within your own organization, and a bigger number for your next comp package are in your future? Not so fast.</span> Though you may be confident of your skills and past performance, you may be the only one. Be warned: In this rocky economic landscape, those responsible for assessing and valuing C-suite talent are assessing candidates with fresh eyes.</p>
my transform snippet looks like this:
Code: Select all
<xsl:template match="p">
<xsl:choose>
...
<xsl:when test="span[@class=x-first-para]">
<p><xsl:apply-templates/></p></xsl:when>
...
</xsl:choose></xsl:template>
Code: Select all
<xsl:template match="span">
<span class="article_subhead">
<xsl:if test="@class='x-first-para'"></xsl:if>
<xsl:value-of select="."/>
</span>
</xsl:template>
-
- Posts: 846
- Joined: Mon Dec 05, 2011 6:04 pm
Re: span tags in html to html conversion
Hello,
In order that the stylesheet you use in your transformation scenario to recognize the elements from the input html document you should declare the prefixed namespace of your input html file.
Then your template should match the prefixed "span" element and change its "class" attribute to the one you need ("article_runin").
You can see an example of how to do that below:
Regards,
Costin
In order that the stylesheet you use in your transformation scenario to recognize the elements from the input html document you should declare the prefixed namespace of your input html file.
Then your template should match the prefixed "span" element and change its "class" attribute to the one you need ("article_runin").
You can see an example of how to do that below:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0" xmlns:prefix="http://www.w3.org/1999/xhtml" exclude-result-prefixes="#all">
<xsl:template match="prefix:span">
<span class="article_runin">
<xsl:if test="@class='x-first-para'"></xsl:if>
<xsl:value-of select="."/>
</span>
</xsl:template>
</xsl:stylesheet>
Costin
Costin Sandoi
oXygen XML Editor and Author Support
oXygen XML Editor and Author Support
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ 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