Jump to content

Use xhtml inside XML (based on XSL)


olav78
 Share

Recommended Posts

I have a XSL-file who generate output to a browser through information in a XML-file. It works fine, but now I also want to use some xhtml-tags in this XML-file. I've tried to do it like this when i want to use xtml-tags:

<strong xmlns="http://www.w3.org/1999/xhtml">strong text</strong>.

But it does not seem to work. The browser shows the text, but not as «strong». Do I need to include a DTD-file or something? Anyone knows?

Link to comment
Share on other sites

I believe the correct way to do that would be to make it strong in the XSL file or you could add an atribute to the tag that has the content you want strong like cssclass="strong" then you can check for this in your XSL and apply the proper CSS at that point.

Link to comment
Share on other sites

but I have <text>-tags in my xml with a lot of text, and I just want to use xhtml-tags like <strong>, <p>, <font> etc to manipulate the presentation of the text... Sounds like a lot of work if i'm going to specify tags in the xslt for this when it's just plain (x)html...

Link to comment
Share on other sites

ok I see what you mean. Does the XML give you errors if you mix the xhtml tags in?Can you post a screen shot of the results after you transform the XML?Also posting your xml file and xsl would help too.

Link to comment
Share on other sites

yup,help.xsl:

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	<xsl:template match="/">		<html>			<head>			<style type="text/css">					div#top{ 							margin: 5px 0 40px 0;						padding: 2px 2px 0px 2px;						color: black;						background: #198fbf;					}					div#menu {							float: left;						width: 120px;						display: inline;						background: #d6d6d6;					}					div#content {						position: absolute;						left:130px;						width: 440px;						margin: 5px 10px;						padding: 0;					}					ul#list{						padding-left: 5px;						margin: 10px auto 10px 5px;						list-style-type: none;					}					li#head {						font-weight: bold;						margin-top: 6px;					}					li#element {					}					a#menu{						text-decoration: none;						font-size: 90%					}			</style>			</head>			<body>				<div id="top">		   			<img src="../images/oppie-logo.jpg"/>		   		</div>		   		<div id="menu">		   			<ul id="list">						<xsl:for-each select="help/category">							<li id="head"><a>							<xsl:attribute name="href">								  #<xsl:value-of select="@name"/>							</xsl:attribute>							<xsl:value-of select="@name"/>							</a></li>							<xsl:for-each select="help-element">								<li id="element"><a id="menu" >								<xsl:attribute name="href">									  #<xsl:value-of select="@id"/>								</xsl:attribute>								<xsl:value-of select="@id"/>								</a></li>							</xsl:for-each>						</xsl:for-each>					</ul>				</div>				<div id="content">				<h1><xsl:value-of select="help/main-heading"/></h1>				<xsl:value-of select="help/text"/>					<xsl:for-each select="help/category">						<h2>							<a>								<xsl:attribute name="name">									  <xsl:value-of select="@name" />								</xsl:attribute>								<xsl:value-of select="@name" />							</a>						</h2>						<xsl:value-of select="text"/>						<xsl:for-each select="help-element">							<h3>								<a>									<xsl:attribute name="name">										  <xsl:value-of select="@id" />									</xsl:attribute>									<xsl:value-of select="@id" />								</a>							</h3>							<p><xsl:value-of select="text" /></p>						</xsl:for-each>					</xsl:for-each>				</div>			</body>		</html>	</xsl:template></xsl:stylesheet>

Here's the help.xml:

<?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="../styles/help.xsl"?><help>	<main-heading>OMS Online Help</main-heading>	<text><strong xmlns="http://www.w3.org/1999/xhtml">strong text</strong> text text text etc</text>	<category name="Operations">		<text>innledende tekst om operation om ønskelig</text>		<help-element id="Minibar locking">			<text>			The OMS can be configured to deny access to a set of products. Which products are defined in the locking policy. The locking can be applied to one or more rooms for a specified time period.			</text>		</help-element>		<help-element id="Locking policies">			<text>			A locking policy specifies the set of products to be locked. The set can consist of all products in the minibar or only a selection, as for example all alcoholic beverages.			</text> 		</help-element>	</category>		....</help>

"<text><strong xmlns="http://www.w3.org/1999/xhtml">strong text</strong> text text text etc</text>" show like "strong text text text text etc" whitout the xhtml formating...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...