|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
Try changing
<xsl:template match="ViewContext"> to <xsl:template match="/ViewContext"> A pecularity of the language... |
|
#3
|
|||
|
|||
|
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. *************** |
|
#4
|
|||
|
|||
|
<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... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Transform ignoring my XSL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|