Using IF statements for differentiating between several xhtml metatags
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 6
- Joined: Wed Feb 15, 2012 5:45 pm
Using IF statements for differentiating between several xhtml metatags
Hi,
In my source xhtml I have three metatags in the head as follows:
In my xslt, I currently have
which returns
However I would like the follwing
So I thought about using <xsl:if>, but really don't know the syntax for working it through.
I would like to implement something like:
Any suggestions or help would be excellent.
Kind Regards
Lewis
In my source xhtml I have three metatags in the head as follows:
Code: Select all
<!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">
<head>
<title>blah blah</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="keywords" content="keywordone, keywordtwo, keywordthree" />
<meta name="revised" content="2010-2-15T14:50:7+0"/>
...
</head>
Code: Select all
<xsl:template match="html:meta"
<dc:modified>
<xsl:value-of select="@content"/>
</dc:modified>
Code: Select all
<dc:modified>text/html; charset=UTF-8</dc:modified>
<dc:modified>keywordone, keywordtwo, keywordthree</dc:modified>
<dc:modified>2010-2-15T14:50:7+0</dc:modified>
Code: Select all
<dc:content>text/html; charset=UTF-8</dc:content>
<dc:description>keywordone, keywordtwo, keywordthree</dc:description>
<dc:modified>2010-2-15T14:50:7+0</dc:modified>
I would like to implement something like:
Code: Select all
If
@meta, content=date format
then
<dc:modified>
<xsl:value-of select=".">
<dc:modified>
else if
@meta, content=keywordone, ...
then
<dc:description>
<xsl:value-of select=".">
<dc:modified>
else
@meta, content=text/html
then
<dc:content>
<xsl:value-of select=".">
<dc:content>
Kind Regards
Lewis
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Using IF statements for differentiating between several xhtml metatags
Hi,
It's simple, use a more explicit XPath match for each type of meta. The order is also important, the most generic match must be used at the end:
Regards,
Adrian
It's simple, use a more explicit XPath match for each type of meta. The order is also important, the most generic match must be used at the end:
Code: Select all
<xsl:template match="html:meta[@name='keywords']"
<dc:description>
<xsl:value-of select="@content"/>
</dc:description>
<xsl:template match="html:meta[@name='revised']"
<dc:modified>
<xsl:value-of select="@content"/>
</dc:modified>
<xsl:template match="html:meta"
<dc:content>
<xsl:value-of select="@content"/>
</dc:content>
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
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