[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Name space confusion

Subject: Name space confusion
From: "Hugh Dixon" <hugh.dixon@xxxxxxxxxxxxxx>
Date: Fri, 31 Oct 2003 12:39:53 +1100
landxml
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.