XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 14th, 2004, 02:08 AM
Culland Culland is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 38 Culland User rank is Private First Class (20 - 50 Reputation Level)Culland User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 55 m 6 sec
Reputation Power: 6
Transform ignoring my XSL

Having a problem where my XSL transformation (using sablotron) is ignoring my XSL and just outputing all text.

I am getting the XML from a remote server, and after much cutting and pasting I have narrowed down the problem. If I have this xml (much shortened form):

<?xml version="1.0" encoding="UTF-8" ?>
<ViewContext version="1.0.0" id="GDPContextServer-uniqueID" xmlns="http://www.opengis.net/context" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gdp="http://geodiscover.cgdi.ca" xsi:schemaLocation="http://www.opengis.net/context http://schemas.opengis.net/context/1.0.0/context.xsd">
<General>
<Window width="400" height="400" />
<BoundingBox SRS="EPSG:4326" minx="-120" miny="49" maxx="-110" maxy="60" />
<Title>GDP search results</Title>
<city>Ottawa</city>
</General>
</ViewContext>

I get back all the text in the xml document in one blurb, however if change <ViewContext> to remove xmlns="http://www.opengis.net/context" it works just like it should. Anyone have an idea of why this occuring. My test XSL is:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="ViewContext">
<html>
<head>
<title>Test</title>
</head>
<body>
<xsl:value-of select="General/Title" />
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Thanks,

Cul

Reply With Quote
  #2  
Old October 15th, 2004, 01:04 PM
jkmyoung jkmyoung is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 505 jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 5 h 22 m 19 sec
Reputation Power: 53
Try changing
<xsl:template match="ViewContext"> to
<xsl:template match="/ViewContext">

A pecularity of the language...

Reply With Quote
  #3  
Old October 15th, 2004, 01:42 PM
Culland Culland is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 38 Culland User rank is Private First Class (20 - 50 Reputation Level)Culland User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 55 m 6 sec
Reputation Power: 6
I tried that, same problem. On a mail list I recieved the following reply, and I have had some luck getting it to work, least farther ahead than I was

Cul

************
The problem is that your ViewContext element in your xml file belongs to the namespace, while your match expression targets ViewContext elements from no namespace. The same is true for other elements.

What you need is something like this:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ctx="http://www.opengis.net/context">
<xsl:template match="ctx:ViewContext">
...

This is a common XPath vs. Namespaces trap.
***************

Reply With Quote
  #4  
Old October 18th, 2004, 12:54 PM
jkmyoung jkmyoung is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 505 jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 5 h 22 m 19 sec
Reputation Power: 53
<xsl:value-of select="General/Title" />
turns into:
<xsl:value-of select="ctx:General/ctx:Title" />

ahh that problem is a pain, you have to pretty much mark everything inside that element as being in that namespace...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Transform ignoring my XSL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT