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

RE: Special characters and Transformation

Subject: RE: Special characters and Transformation
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 5 May 2006 16:15:33 +0100
ascii indent
If you want the TEXT element to be in the http://www.fo.com namespace then
you should say so:

<xsl:element name="TEXT" namespace="http://www.fo.com">

The xmlns="" has been added because you asked for the TEXT element to be in
the null namespace.

This code would be a lot more readable if you used literal result elements.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Khorasani, Houman [mailto:Houman.Khorasani@xxxxxxxxxxxx]
> Sent: 05 May 2006 16:02
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Special characters and Transformation
>
> Florent,
>
> Many thanks for the examples.  They didn't work by themselves
> but gave me a pretty nice idea:
>
> That's what I created:
> <?xml version="1.0" encoding="us-ascii"?> <xsl:stylesheet
> version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:f="http://www.fo.com" exclude-result-prefixes="f">
> 	<xsl:output method="xml" version="1.0"
> encoding="us-ascii" indent="yes"/>
>
> 	<xsl:template match="/">
> 		<xsl:apply-templates select="*"/>
> 	</xsl:template>
>
> 	<xsl:template match="f:root">
> 		<xsl:element name="root" namespace="http://www.fo.com">
> 			<xsl:apply-templates/>
> 		</xsl:element>
> 	</xsl:template>
>
> 	<xsl:template match="f:TEXT">
> 		<xsl:element name="TEXT">
> 			<xsl:element name="Tag">
> 				<xsl:value-of select="f:Tag"/>
> 			</xsl:element>
> 		</xsl:element>
> 	</xsl:template>
> </xsl:stylesheet>
>
>
> It is very close to where I want to be:
>
> <?xml version="1.0" encoding="us-ascii"?> <root
> xmlns="http://www.fo.com">
> 	<TEXT xmlns="">
> 		<Tag>Als die ersten St&#228;dte zu einer
> Gr&#246;&#223;e heranwuchsen</Tag>
> 	</TEXT>
> </root>
>
>
> However how do I get rid of <TEXT xmlns="">? It should be
> plain <TEXT> in the output?
>
> Many thanks for any advice,
> Houman
>
>
>
>
> -----Original Message-----
> From: Florent Georges [mailto:darkman_spam@xxxxxxxx]
> Sent: 05 May 2006 12:00
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Special characters and Transformation
>
> Florent Georges wrote:
>
> >   BTW, I suggest you to take a look at "Literal Result Elements",
> > "Template Rules", and maybe the "Modified Identity Tranformation
> > Pattern".
>
>   It is not really explicit.  Starting from your code:
>
>     <xsl:stylesheet
>         version="1.0"
>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>       <xsl:output method="xml" version="1.0"
>                   encoding="us-ascii" indent="yes"/>
>       <xsl:template match="/">
>         <xsl:element name="root" namespace="http://www.fo.com">
>           <xsl:for-each select="Text">
>             <xsl:element name="Text">
>               <xsl:element name="tag">
>                 <xsl:value-of select="tag"/>
>               </xsl:element>
>             </xsl:element>
>           </xsl:for-each>
>         </xsl:element>
>       </xsl:template>
>     </xsl:stylesheet>
>
> "Literal Result Elements" let you write:
>
>     <xsl:stylesheet
>         version="1.0"
>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>       <xsl:output method="xml" version="1.0"
>                   encoding="us-ascii" indent="yes"/>
>       <xsl:template match="/">
>         <f:root xmlns:f="http://www.fo.com">
>           <xsl:for-each select="root/Text">
>             <Text>
>               <tag>
>                 <xsl:value-of select="tag"/>
>               </tag>
>             </Text>
>           </xsl:for-each>
>         </f:root>
>       </xsl:template>
>     </xsl:stylesheet>
>
> "Template Rules" let you write:
>
>     <xsl:stylesheet
>         version="1.0"
>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>       <xsl:output method="xml" version="1.0"
>                   encoding="us-ascii" indent="yes"/>
>       <xsl:template match="/">
>         <xsl:apply-templates/>
>       </xsl:template>
>       <xsl:template match="root">
>         <f:root xmlns:f="http://www.fo.com">
>           <xsl:apply-templates/>
>         </f:root>
>       </xsl:template>
>       <xsl:template match="Text">
>         <Text>
>           <xsl:apply-templates select="tag"/>
>         </Text>
>       </xsl:template>
>       <xsl:template match="tag">
>         <tag>
>           <xsl:value-of select="tag"/>
>         </tag>
>       </xsl:template>
>     </xsl:stylesheet>
>
> and "Modified Identity Tranformation Pattern" let you write:
>
>     <xsl:stylesheet
>         version="1.0"
>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>       <xsl:output method="xml" version="1.0"
>                   encoding="us-ascii" indent="yes"/>
>       <xsl:template match="@*|node()">
>         <xsl:copy>
>           <xsl:apply-templates select="@*|node()"/>
>         </xsl:copy>
>       </xsl:template>
>       <xsl:template match="root">
>         <f:root xmlns:f="http://www.fo.com">
>           <xsl:apply-templates/>
>         </f:root>
>       </xsl:template>
>       <xsl:template match="Text">
>         <xsl:copy>
>           <xsl:apply-templates select="tag"/>
>         </xsl:copy>
>       </xsl:template>
>     </xsl:stylesheet>
>
> or (depending on your real usage):
>
>     <xsl:stylesheet
>         version="1.0"
>         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>       <xsl:output method="xml" version="1.0"
>                   encoding="us-ascii" indent="yes"/>
>       <xsl:template match="@*|node()">
>         <xsl:copy>
>           <xsl:apply-templates select="@*|node()"/>
>         </xsl:copy>
>       </xsl:template>
>       <xsl:template match="root">
>         <f:root xmlns:f="http://www.fo.com">
>           <xsl:apply-templates/>
>         </f:root>
>       </xsl:template>
>       <xsl:template match="junk|junk2"/>
>     </xsl:stylesheet>
>
>   Regards,
>
> --drkm
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ______________________________________________________________
> _____________
> Faites de Yahoo! votre page d'accueil sur le web pour
> retrouver directement vos services prifiris : virifiez vos
> nouveaux mails, lancez vos recherches et suivez l'actualiti
> en temps riel.
> Rendez-vous sur http://fr.yahoo.com/set

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.