[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XHTML to XHTML transform

Subject: Re: XHTML to XHTML transform
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 02 Apr 2004 17:24:06 -0500
link transform
Jeff,

Try match="text()[parent::mynamespace:*]"

A text node isn't in a namespace, but its parent element may be. The predicate (bracketed expression) here filters out text nodes whose parent is not in the 'mynamespace' namespace (so the pattern matches only those whose parents are in it).

In general, where you have:
<xsl:template match="nbn:link">
  <xsl:element name="A">
    <xsl:attribute name="HREF">/<xsl:value-of
select="$controller"/>/module/<xsl:value-of
select="nbn-var:location/nbn-var:module" />/action/<xsl:value-of
select="nbn-var:location/nbn-var: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>

you could have


<xsl:template match="nbn:link">
<A HREF="{$controller}/module/{nbn-var:location/nbn-var:module}/action/{nbn-var:location/nbn-var:action}/" ID="{@id}" CLASS="menuitem">
<xsl:value-of select="@name"/>
</A>
<xsl:apply-templates/>
<BR/>
<xsl:apply-templates select="link"/>
</xsl:template>


<xsl:template match="link">
  <DIV CLASS="submenu">
    <!-- plus whatever else happens to 'link'...
         apply-templates, copy or whatever -->
  </DIV>
</xsl:template>

... which is exactly the same, but put more concisely.

Cheers,
Wendell

At 04:55 PM 4/2/2004, you wrote:
How do I match text nodes in my custom namespace? As in override the default
text node template for "mynamespace"?

All my variables <mynamespace:name>blah</mynamespace:name> for instance
appear as text in the results, I've tried this:

<xsl:template match="text()[namespace-uri()='mynamespace:namespace']">
</xsl:template>

but that doesn't work... I ended up changing all the elements I want hidden
under all circumstances to the mynamespace-var namespace...

<xsl:template match="*[namespace-uri()='mynamespace-var:namespace']">
</xsl:template>

This works, but I think its messy, I was wondering if there was a better
way? I'm pasting my code below.


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.