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

stylesheet not work when xmlns exist

Subject: stylesheet not work when xmlns exist
From: lee qm <akimilee@xxxxxxxxx>
Date: Sat, 26 Sep 2009 08:48:40 +0800
 stylesheet not work when xmlns exist
I am on xlst 1.0,

This is my stylesheet,

	<xsl:template match="/Request">
	<data>
	<Elem n="{name(.)}">
	<xsl:for-each select="@*">
	<xsl:if test="name(.)='System'">
		<attr n="{name(.)}">
		<xsl:element name="val">
			<xsl:attribute name="s">
				<xsl:value-of select="normalize-space(.)"/>
			</xsl:attribute>
		</xsl:element>
		</attr>
	</xsl:if>
	</xsl:for-each>
	<xsl:apply-templates/>
	</Elem>
	</data>
	</xsl:template>

I only want to get the "System" attribute and ignore all the rest.
The stylesheet works perfectly fine and generate following output-1
when I use input-1 and input-2 as below.

input-1:
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="abc.xsd" System="mysystem">
</Request>

input-2:
<?xml version="1.0" encoding="UTF-8"?>
<Request abc="myabc" System="mysystem">
</Request>

output-1:
<?xml version="1.0" encoding="utf-8"?>
<data>
   <Elem n="Request">
      <attr n="System">
         <val s="mysystem"/>
      </attr>
   </Elem>
</data>


THE PROBLEM arise when the input is with xmlns without prefix "xsi",
the output that is output-3 as below:

input-3: Remove the xsi prefix from xmlns
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://www.abc.com"  System="mysystem">
</Request>

output-3:
<?xml version="1.0" encoding="utf-8"?>


I have no idea why "xmlns" is causing problem here?

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-2011 All Rights Reserved.