Subject: [xsl] Name space confusion From: "Hugh Dixon" <hugh.dixon@xxxxxxxxxxxxxx> Date: Fri, 31 Oct 2003 12:39:53 +1100 |
I am wanting to write stylesheets that can be used by xml files from a variety of sources I have trouble because the name space is not always specified by the supplier. I would like to be able to match on an element of known local name, but from a, possibly undefined namespace. I suspect part of the problem is that I'm creating elements of my own (undefined) namespace. The problem is, of course, with the supplier, not with me and what I'm trying to do :) The good and bad in my names refer to the result, not that it is good to have no namespace, and bad to have one. sampleBad XML <LandXML xmlns="http://www.landxml.org/schema/LandXML-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.landxml.org/schema/LandXML-1.0 http://www.landxml.org/schema/LandXML-1.0/LandXML-1.0.xsd" version="1.0" date="2002-01-28" time="10:08:09" readOnly="false" language="English"> <CgPoints> <CgPoint name="1">1145.99755444 -626.27773323 0.000000</CgPoint> <CgPoint name="2">1759.50228244 -493.99972666 0.000000</CgPoint> </CgPoints> </LandXML> sampleGood XML <LandXML> <CgPoints> <CgPoint name="1">1145.99755444 -626.27773323 0.000000</CgPoint> <CgPoint name="2">1759.50228244 -493.99972666 0.000000</CgPoint> </CgPoints> </LandXML> Sample XSL <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/"> <xsl:element name="myNewRoot"> <xsl:for-each select=".//CgPoints"> <xsl:element name="SomeOtherThing"> <xsl:apply-templates select="."/> </xsl:element> </xsl:for-each> </xsl:element> </xsl:template> <xsl:template match="CgPoints"> <xsl:element name="myFirstLevelChild"> </xsl:element> </xsl:template> </xsl:stylesheet> I can set up a lml namespace in my style sheet, and change the matches etc by adding the lml prefix, however if I do this it just reverses the problem. I'd like a stylesheet that will work with either example. I'm not very good with namespaces, and names, so hope there is a simple solution. Thanks!! Hugh XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Import precedence with im, Justin Makeig | Thread | RE: [xsl] Name space confusion, Lars Huttar |
RE: [xsl] String Trouble, Americo Albuquerque | Date | RE: [xsl] Name space confusion, Lars Huttar |
Month |