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

Re: default namespace on input document

Subject: Re: default namespace on input document
From: Vasu Chakkera <vasucv@xxxxxxxxx>
Date: Tue, 15 Feb 2011 14:56:31 +0000
Re:  default namespace on input document
>> This is probably a trivial issue, but I'm new to XSL 2.

Basically this is to do with both XSLT1 and 2
Your Xpaths work relative to the namespace ...
So if your document element is in a perticular namespace, then your
Xpaths should change accordingly..
You can come across this by either
**************telling your stylesheet what the default namespace would
be  by using  xpath-default-namespace=""
 OR
***********  declaring a namespace prefix in the stylesheet and    use
it to refer to the nodes in the xpath
like xmlns:myns = "http://foo.com"

and then refer to the nodes like myns:nodename

also...

with ,,,
<xsl:template match="/">
             <xsl:apply-templates select="." />
      </xsl:template>

      <xsl:template match="node() | @*">
             <xsl:copy>
                    <xsl:apply-templates select="node() | @*"/>
             </xsl:copy>
      </xsl:template>

You are very very likely to run into Infinite recursion ....

you probably want ...

somethiing like this...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:mns = "http://www.w3.org/1999/xhtml"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="node() | @*">
		<xsl:copy>
			<xsl:apply-templates select="node() | @*"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="mns:body">
		<!-- never matched -->
             hi
     <xsl:sequence select="."/>
	</xsl:template>
</xsl:stylesheet>

hth
Vasu Chakkera..

2011/2/15 Merrilees, David <David.Merrilees@xxxxxxxxxxxx>:
> Hi
>
> I'm having trouble matching a template in XSLT2. When I add a default
namespace to my input document, my templates no longer match any elements.
>
> Input:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml">
>       <head>
>              <title>Text Chybljmcm for key: Welcome in cs-CZ</title>
>              <meta charset="utf-8" />
>       </head>
>       <body id="home">
>              <div id="footer">
>                     <p>
>                           (c) Tesco.com 2011
>                     </p>
>              </div>
>       </body>
> </html>
>
> XSL:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet
>       version="2.0"
>       xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>       exclude-result-prefixes="xsl">
>
>       <xsl:template match="/">
>              <xsl:apply-templates select="." />
>       </xsl:template>
>
>       <xsl:template match="node() | @*">
>              <xsl:copy>
>                     <xsl:apply-templates select="node() | @*"/>
>              </xsl:copy>
>       </xsl:template>
>
>       <xsl:template match="body">
>              <!-- never matched -->
>              hi
>              <xsl:sequence select="."/>
>       </xsl:template>
>
> </xsl:stylesheet>
>
> This is probably a trivial issue, but I'm new to XSL 2.
>
> Thanks
>
> David Merrilees
>
> This is a confidential email. Tesco may monitor and record all emails. The
views expressed in this email are those of the sender and not Tesco.
>
> Tesco Stores Limited
> Company Number: 519500
> Registered in England
> Registered Office: Tesco House, Delamare Road, Cheshunt, Hertfordshire EN8
9SL
> VAT Registration Number: GB 220 4302 31
>
>



--
Vasu Chakkera
NodeLogic Limited
Oxford
www.nodelogic.org
==============

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.