Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   XSL Transform Prevented by a Declaration (http://www.velocityreviews.com/forums/t296399-xsl-transform-prevented-by-a-declaration.html)

Al Hatch 06-04-2006 02:51 PM

XSL Transform Prevented by a Declaration
 
XSLT fails when the XML file contains this top-level declaration:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<P2Main xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:schemas-Professional-Plug-in:P2:ClipMetadata:v3.0">
<ClipName>0001FM</ClipName>
</P2Main>

However, XSLT succeeds when I modify the XML declaration to this:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<P2Main>
<ClipName>0001FM</ClipName>
</P2Main>

What is the declaration conflict here, and why would that simple deletion
make it work?


By the way, the XSL is

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:value-of select="P2Main/ClipName"/>
</xsl:template>
</xsl:stylesheet>


Martin Honnen 06-04-2006 02:54 PM

Re: XSL Transform Prevented by a Declaration
 


Al Hatch wrote:

> XSLT fails when the XML file contains this top-level declaration:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
> <P2Main xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="urn:schemas-Professional-Plug-in:P2:ClipMetadata:v3.0">
> <ClipName>0001FM</ClipName>
> </P2Main>



> <xsl:stylesheet version="1.0"


Add
xmlns:cm="urn:schemas-Professional-Plug-in:P2:ClipMetadata:v3.0"

> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


and then use e.g.

> <xsl:template match="/">
> <xsl:value-of select="P2Main/ClipName"/>


<xsl:value-of select="cm:P2Main/pm:ClipName" />


--

Martin Honnen
http://JavaScript.FAQTs.com/

Al Hatch 06-04-2006 04:21 PM

Re: XSL Transform Prevented by a Declaration
 
On Sun, 4 Jun 2006 07:54:47 -0700, Martin Honnen wrote
(in article <4482f43b$0$4498$9b4e6d93@newsread2.arcor-online.net>):

> <xsl:value-of select="cm:P2Main/pm:ClipName" />


There was a typo in your repsonse (/pm should be /cm), but once I changed
that, it worked.

Apparently, namespace declarations in the XSL document must match the
namespace declarations in its source XML document, but I'm not clear on what
the cm namespace is. I guess I have to go back to the manual to find out
what's going on here.

Thanks.


Martin Honnen 06-04-2006 04:44 PM

Re: XSL Transform Prevented by a Declaration
 


Al Hatch wrote:


> Apparently, namespace declarations in the XSL document must match the
> namespace declarations in its source XML document, but I'm not clear on what
> the cm namespace is. I guess I have to go back to the manual to find out
> what's going on here.


The major problem is that while the XML document contains elements in a
default namespace (declared with xmlns="someURI") XPath needs a prefix
bound to the URL to match elements in the namespace.

--

Martin Honnen
http://JavaScript.FAQTs.com/


All times are GMT. The time now is 05:03 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.