Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] XHTML to XHTML transform

From: "Jeffrey Moss" <jeff@------------>
To:
Date: 4/2/2004 9:06:00 AM
Thanks to all of you, you have cleared up some confusion for me.

Ok, I am a little closer to the solution, here is my XSL (box was next up on
my list):

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:param name="controller" select="'index.php'"/>
<xsl:output method="xml" indent="yes"/>

<xsl:template match="/sitemap">
  <DIV CLASS="navtree">
    <xsl:apply-templates />
  </DIV>
</xsl:template>

<xsl:template match="*">
  <xsl:copy>
    <xsl:apply-templates />
  </xsl:copy>
</xsl:template>

<xsl:template match="link">
  <xsl:element name="A">
    <xsl:attribute name="HREF">/<xsl:value-of
select="$controller"/>/module/<xsl:value-of select="location/module"
/>/action/<xsl:value-of select="location/action" />/</xsl:attribute>
    <xsl:attribute name="ID"><xsl:value-of select="id"/></xsl:attribute>
    <xsl:attribute name="CLASS">menuitem</xsl:attribute>
    <xsl:value-of select="name"/>
  </xsl:element>
  <xsl:apply-templates />
  <BR/>
  <xsl:if test="link">
    <xsl:element name="DIV">
      <xsl:attribute name="CLASS">submenu</xsl:attribute>
      <xsl:apply-templates select="link"/>
    </xsl:element>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>

So now what I did was I added xsl:apply-templates to the middle of the link
template, and I added a default template for all other nodes, I knew I was
on the right track so thanks for the help.

But what I really wanted was that all elements in the XHTML namespace would
be outputted to the results, and all of my extra XML tags like "name" for
instance, wouldn't be copied. Is this what the XHTML namespace is for?

This is the results I end up getting:

<HEAD>
<TITLE>Testing 1 2 3</TITLE>
</HEAD>

  <A HREF="/index.php/module/Products/action/Display/" ID="products"
CLASS="menuitem">Products</A>
    <name>Products</name>
    <id>products</id>
    <short-description>More info on available products</short-description>
    <long-description>We have a variety of products to offer, to suit a wide
range of end users, from communications, to internet access, and the list
keeps growing! Check back often to see what we can do for
you.</long-description>
    <location>
      <module>Products</module>
      <action>Display</action>
    </location>

    <A HREF="/index.php/module/DialOne/action/Display/" ID="longdistance"
CLASS="menuitem">Long Distance</A>


Is there any way to do this? Once again, thanks for all the help.

-Jeff

----- Original Message ----- 
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, April 02, 2004 11:48 AM
Subject: RE: [xsl] XHTML to XHTML transform


> > -----Original Message-----
> > From: Jeffrey Moss [mailto:jeff@xxxxxxxxxxxx]
> >
> <snip />
> > I have tried a number of different approaches already. I played
> > around with the xmlns:xhtml namespace in my XSL file (not sure if I ever
> did this
> > correctly, I don't think I fully understand what namespaces do).
> >
>
> Hi,
>
> What exactly is it that is not working?
>
> If your supplied source and desired target format were plain XML the
> solution would look like:
>
> <xsl:template match="BODY">
>   <xsl:copy>
>     <xsl:apply-templates />
>   </xsl:copy>
> </xsl:template>
>
> <xsl:template match="BOX">
>   <DIV ID="box">
>     <xsl:apply-templates />
>   </DIV>
> </xsl:template>
>
> <xsl:template match="TITLE">
>   <DIV ID="top">
>     <DIV ID="topleft" />
>     <DIV ID="topright" />
>     <SPAN ID="title">
>       <xsl:apply-templates />
>     </SPAN>
>   </DIV>
> </xsl:template>
>
> <xsl:template match="FOOTER">
>   <DIV ID="bottom">
>     <DIV ID="bottomleft" />
>     <DIV ID="bottomright" />
>     <SPAN ID="footer">
>       <xsl:apply-templates />
>     </SPAN>
>   </DIV>
> </xsl:template>
>
> If you really want to you could combine the latter two templates, since
they
> output something very similar. The 'Hello World' text will be copied
because
> of the default template rule for text-nodes (same as the content of the
> TITLE / FOOTER nodes)
>
> Now, depending upon your source files (prefixed elements / namespaces),
you
> may need to make it something like:
>
> <xsl:template match="html:BODY">
> or
> <xsl:template match="*[local-name()='BODY']">
>
> > I also played with the xsl:output tag to see if I could get that to do
> > something cool, but no.
> >
>
> In XSLT 1.0 the options are: xml / text / html
>
> As you want to ouput XHTML, if you use xsl:output, you need to specify XML
> as your output target.
>
> Hope this helps!
>
> Cheers,
>
> Andreas


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent