I found my solution:

For reference, here was my starting point.

In the XML file I have the namespace declarations:

<comwpc:page
  xmlns="http://www.w3.org/1999/xhtml";
  xmlns:comwpc="http://commerce.wi.gov/xmlns/comwpc";
  xmlns:comwpm="http://commerce.wi.gov/xmlns/comwpm";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="
      http://www.w3.org/1999/xhtml  /schema/com-1_0.xsd
      http://commerce.wi.gov/xmlns/comwpc
/schema/com-content-module-1_0.xsd
      http://commerce.wi.gov/xmlns/comwpm  /schema/com-meta-module-1_0.xsd
      http://www.w3.org/XML/1998/namespace  http://www.w3.org/2001/xml.xsd
  ">

with the html elements coded as <a>, <strong> etc.

In the xsl file I have (note the default declaration
xmlns="http://www.w3.org/1999/xhtml";)

<xsl:transform version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns="http://www.w3.org/1999/xhtml"; 
  xmlns:comwpc="http://commerce.wi.gov/xmlns/comwpc";
  xmlns:comwpm="http://commerce.wi.gov/xmlns/comwpm";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  exclude-result-prefixes="xsl comwpc comwpm xsi"
>

and refer to the html elements with 

<template match="a">

Nothing happens.


In the XML file I keep the namespace declaration in the XML such as 

<comwpc:page
  xmlns="http://www.w3.org/1999/xhtml";
  xmlns:comwpc="http://commerce.wi.gov/xmlns/comwpc";
  xmlns:comwpm="http://commerce.wi.gov/xmlns/comwpm";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="
      http://www.w3.org/1999/xhtml  /schema/com-1_0.xsd
      http://commerce.wi.gov/xmlns/comwpc
/schema/com-content-module-1_0.xsd
      http://commerce.wi.gov/xmlns/comwpm  /schema/com-meta-module-1_0.xsd
      http://www.w3.org/XML/1998/namespace  http://www.w3.org/2001/xml.xsd
  ">

with the html elements still coded as <a>, <strong> etc.

In the xsl file I have added :xhtml to the namespace declaration for the
default (note the default declaration now reads
xmlns:html="http://www.w3.org/1999/xhtml"; 

<xsl:transform version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:html="http://www.w3.org/1999/xhtml";
  xmlns:comwpc="http://commerce.wi.gov/xmlns/comwpc";
  xmlns:comwpm="http://commerce.wi.gov/xmlns/comwpm";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  exclude-result-prefixes="xsl comwpc comwpm xsi"
>

and change the refernece to the element as 

<template match = "html:a" >

it works. 

Is my understanding correct, the xhtml elements need a namespace value to
work in the xsl processor?

Gary T. Schultz
Web Technical Administrator / GIS Coordinator
Wisconsin Department of Commerce
6th Floor
P.O. Box 7970
Madison, WI 
1-608-266-1283


-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, August 24, 2004 4:35 AM
To: [EMAIL PROTECTED]
Subject: Re: matching html elements in transformation


Antony Quinn wrote:
> Gary,
> 
> It sounds like a namespace problem.
> 
> Take a look at your HTML - if there's a DTD declaration you'll need to 
> declare this is a namespace in your XSL file and prefix any HTML 
> elements accordingly, eg:

No. DTD and namespace are separate things.
Just only check if HTML given has a namespace. And if there is none you 
don't have to add one, regardless which DTD. If HTML had a namespace it 
should be mentioned in the starting tag of its root element like
  <html xmlns=""> ... </html>
Normally (non-X)HTML doesn't allow for a namespace attribute.

-- 
Volkmar W. Pogatzki


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to