RE: Re: [xsl] Filemaker XSL woes

Subject: RE: Re: [xsl] Filemaker XSL woes
From: cknell@xxxxxxxxxx
Date: Thu, 27 Jul 2006 09:28:24 -0400
A namespace is indicated by the inclusion of the "xmlns=''" attribute. It's purpose is to distinguish elements from one another. For example, if there are two "Johns" in your school or office, you would customarily distinguish them by using a surname to qualify them. Thus you know that "John Smith" is different from "John Jones" because one is in the "Smith namespace" while the other is in the "Jones namespace". 

Your sample xml has such an attribute:
xmlns="http://www.filemaker.com/fmpxmlresult";

Consequently, all nodes in the document are in the "http://www.filemaker.com/fmpxmlresult"; namespace.

The opening tag of an XSLT stylesheet usually looks like this:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
or
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

This tells the processor that all element names prefixed with "xsl:" belong in the "http://www.w3.org/1999/XSL/Transform"; namespace.

Because "http://www.filemaker.com/fmpxmlresult"; is declared without a prefix, it is said to be an "anonymous namespace".

Your XSLT file has to make mention of this namespace and give it an alias for the stylesheet to "see" the nodes in the source document. You could do this by including a namespace declaration in the <xsl:stylesheet> opening tag similar to the xsl namespace declaration. 

Unlike personal names in the English-speaking world where the "family namespace" appears after the given name, in the xml world, namspaces are indicated by a prefix and a colon.

What form that prefix takes is not material so long as it is within the bounds of namespace naming rules and isn't the same as any other prefix used in any of the documents involved in the transformation. There's nothing magical about the particular letters used in a prefix.

So, you might change your <xsl:stylesheet> opening tag to read like this:

<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:fmp="http://www.filemaker.com/fmpxmlresult";>

Thereafter in your stylesheet, any time you want to access a node from the source document, you will prefix the name with "fmp:".

Thus a template to match the root element would read like this:

<xsl:template match="fmp:FMPXMLRESULT">
</xsl:template>


-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Chad Chelius <cchelius@xxxxxxxxxxxxxxx>
Sent:     Thu, 27 Jul 2006 08:40:22 -0400
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re: [xsl] Filemaker XSL woes

Mike,
I am new to XSLT so forgive me if this seems obvious. I have included  
a snippet of code for you to look at. What does it mean if it uses a  
namespace? I see that there is an attribute for xmlns=. Is that  
defining the namespace? Thanks for your response!


<?xml version="1.0" encoding="UTF-8" ?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult";>
     <ERRORCODE>0</ERRORCODE>
     <PRODUCT BUILD="09-16-2004" NAME="FileMaker Pro" VERSION="7.0v3"/>
     <DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="Employee  
Database.fp7" RECORDS="16"
         TIMEFORMAT="h:mm:ss a"/>
     <METADATA>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="First_Name"  
TYPE="TEXT"/>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Last_Name"  
TYPE="TEXT"/>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Address1"  
TYPE="TEXT"/>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Address2"  
TYPE="TEXT"/>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="City" TYPE="TEXT"/>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="State" TYPE="TEXT"/>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Zip" TYPE="TEXT"/>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Home_Phone"  
TYPE="TEXT"/>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Mobile_Phone"  
TYPE="TEXT"/>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Work_Phone"  
TYPE="TEXT"/>
         <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Email" TYPE="TEXT"/>
     </METADATA>
     <RESULTSET FOUND="16">
         <ROW MODID="0" RECORDID="2">
             <COL>
                 <DATA>Jaime</DATA>
             </COL>
             <COL>

On Jul 27, 2006, at 8:12 AM, Mike Ferrando wrote:

> Chad C.,
> Since you supply no code, I will go on memory.
>
> I believe that the Filemaker xml output has a namespace.
>
> Have you written you XSLT with that in mind?

Current Thread