Jump to content

<b> markup


paetje

Recommended Posts

I made a site with content in XML with data islands. They gave a the advise to use XSL for displaying the content. But how can I use tags like <b> and <i>?*I am no that formilliar with the use and declaration of XSL. :)

Link to comment
Share on other sites

I think he means that he wants to use HTML inside an XML document and output the whole containg node, not simply having a <b> element inside XML :) .

Link to comment
Share on other sites

that's correctbut I solved the problem. I made a tag <bold></bold><xsl:template match="bold"> <span class="bold"> <xsl:apply-templates/> </span> </xsl:template>CSS.bold{ font-weight: bold;}

Link to comment
Share on other sites

I'm not sure I understand completely, simple because I don't have much experience with the apply-template element. What's the deal? Where will that work?

<container>In this example, is <bold>this text is suppose to be bold</bold> and the other part of the container a normal text?</container><bold>Or there has to be a single container for the whole bold text?<bold>

If what I suspect is correct, this template should give a span with class bold to every bold element, no matter where it's contain and used(the <container> example) right?

Link to comment
Share on other sites

every tag <bold> gets class bold, CSS style says that the font-weight: bold. So no matter where you put this tag the text will be bold. This count for just one word but can also count for an blok of text.

Link to comment
Share on other sites

this only works if your site is build in a loop:

<xsl:for-each select="website/welkom ">      <xsl:apply-templates /></xsl:for-each>

when XSL apply's the templates he finds this code:

<xsl:template match="nadruk">	<span class="bold">  <xsl:apply-templates/>	</span>	</xsl:template>

and add CSS to it:

.bold {           font-weight:bold;         }

gives the result:this tag is bold but this part of the text to

Link to comment
Share on other sites

I tryed making some experiments with this and I even looked at your previous posts for reference, but I still don't get it. I fell like a complete noob about asking this, but could you please post a full sample XSLT and XML code that will give the results? It's a lot easier for me (personally) to study full codes, than snippets. There's probably something other I haven't taken into consideration.

Link to comment
Share on other sites

my XML

<?xml version="1.0"?><!-- naam van de website--><?xml-stylesheet type="text/xsl" href="welkom.xsl"?><!-- aanroepen XSL --><website naam="De lelie">    <!-- titel website-->   <titel>De lelie </titel> 	  	 <!-- naam van de pagina--> 	 <welkom>      <onderwerp>Welkom</onderwerp>      <content><id>koptekst</id>      <alinea>De Lelie is een <nadruk>groothandel </nadruk>in planten en bloemen.       <afbeelding />Deze site geeft u informatie over ons bedrijf en onze artikelen. <subalinea>Daarnaast vindt u hier ook alles over De Grote Actie!</subalinea></alinea> 	       <alinea>Nieuws alinea, hier vind <nadruk> €</nadruk> al het nieuws</alinea>      </content> 	 </welkom></website>

fisrt XSL, tells the xml how it's supposed so be send to the browser

<?xml version="1.0" encoding="ISO-8859-1" ?><!-- Edited with XML Spy v4.2 --><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method='html' version='1.0' encoding="ISO-8859-1" indent='yes'/><xsl:include href="inc_tags.xsl" /><xsl:template match="/">   <html>  <link rel="stylesheet" type="text/css" href="lelie.css" />	<title>de Lelie</title> 	 <body>  <table class="bordertabel">          <td>   	       <xsl:for-each select="website/welkom ">          <xsl:apply-templates />      </xsl:for-each>   	 </td>   	 </table>         	 </body>  </html></xsl:template>

second XSL tells the first XSL what to do by the following tags

<?xml version="1.0" encoding="ISO-8859-1" ?><xsl:stylesheet	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"	xmlns:fo="http://www.w3.org/1999/XSL/Format"	version="1.0"><!-- uitleg voor de browser, wat moet de browser waar laten zien als hij statements tegenkomt -->	<xsl:template match="welkom">	  <table class="welkom"> 	 <xsl:apply-templates select="content"/>  </table>	</xsl:template>	<xsl:template match="onderwerp">  <tr> 	 <th height="34" valign="top"><xsl:apply-templates/></th>  </tr>		</xsl:template><xsl:template match="content">      	<tr>  <td valign="top"><xsl:apply-templates select="alinea"/></td>	</tr>	</xsl:template><xsl:template match="alinea">	<P>  <xsl:apply-templates/>	</P>	</xsl:template><xsl:template match="subalinea">	<BR/>	<BR/>  <xsl:apply-templates/>	</xsl:template><xsl:template match="volgenderegel">	<BR/>  <xsl:apply-templates/>  </xsl:template><!-- afbeelding invoegen --><xsl:template match="afbeelding">  <img src="pics/001.jpg" /></xsl:template><!-- zoek de tag <nadruk> in het XML document en voer daar de volgende code voor uit --><xsl:template match="nadruk">	<span class="bold">  <xsl:apply-templates/>	</span>	</xsl:template>	</xsl:stylesheet>

the comment is in Dutch and so are the tagnames, but you can give it youre own name. Good luck with it

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
×
×
  • Create New...