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

RE: Trouble writing .xsl

Subject: RE: Trouble writing .xsl
From: Jason Rizer <jasonriz@xxxxxxxxx>
Date: Sun, 13 Jan 2002 15:43:27 -0800 (PST)
videomail yahoo
Finally, everything is working.  Thanks again.

-Jason

--- "Sullivan, Dan" <dsullivan@xxxxxxxxxxx> wrote:
> There are many variations on this depending on the
> exact needs of your
> problem. Watch for line wraps.
> 
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0"
> xmlns:ABC="org.jason">
> <!-- identity transform -->
> <xsl:template match="node()|@*">
>     <xsl:copy>
>         <xsl:apply-templates select="node()|@*"/>
>     </xsl:copy>
> </xsl:template>
> <!-- transform for jason -->
> <xsl:template match="ABC:*">
>     <xsl:choose>
>         <!-- see if local name start with jason -->
>         <xsl:when
> test="substring-before(local-name(.), '.')='jason'">
>             <!-- if so remove it -->
>             <xsl:element name="{concat('ABC:',
> substring-after(local-name(.), '.'))}"
> namespace="org.jason">
>                 <!-- but keep going if there is more
> -->
>                 <xsl:apply-templates
> select="node()|@*"/>
>             </xsl:element>
>         </xsl:when>
>         <xsl:otherwise>
>             <!-- if it is not a jason just copy and
> keep on going -->
>             <xsl:copy>
>                 <xsl:apply-templates
> select="node()|@*"/>
>             </xsl:copy>
>         </xsl:otherwise>
>     </xsl:choose>
> </xsl:template>
> </xsl:stylesheet>
> 
> 
> Dan
> 
> -----Original Message-----
> From: Jason Rizer [mailto:jasonriz@xxxxxxxxx]
> Sent: Sunday, January 13, 2002 11:44 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Trouble writing .xsl
> 
> 
> 
> --- "Sullivan, Dan" <dsullivan@xxxxxxxxxxx> wrote:
> > You need to make use of an identity transform like
> > this:
> > 
> > 
> > <xsl:stylesheet
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > version="1.0"
> > xmlns:ABC="org.jason">
> > 
> > <!-- identity transform, for everything you don't
> > care about changing
> > -->
> > <xsl:template match="@*|node()">
> >     <xsl:copy>
> >         <xsl:apply-templates select="@*|node()"/>
> >     </xsl:copy>
> > </xsl:template>
> > 
> > <!-- transform for jason, the only element you
> care
> > about changing -->
> > <xsl:template match="ABC:jason.Smith">
> > <ABC:Smith>
> > <!-- process children, atrs, if any -->
> >     <xsl:apply-templates select="@*|node()"/>
> > </ABC:Smith>
> > </xsl:template>
> > 
> > </xsl:stylesheet>
> > 
> > 
> > Also your source file had a typo in it (XMI
> > Content).
> > 
> > Dan
> > 
> > -----Original Message-----
> > From: Jason Rizer [mailto:jasonriz@xxxxxxxxx]
> > Sent: Saturday, January 12, 2002 8:54 PM
> > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  Trouble writing .xsl
> > 
> > 
> > Hello,
> > 
> > I've just recently begun using xslt and I'm kind
> of
> > stuck on something pretty simple. I've worked
> > through
> > parts of a couple of tutorials but I still can't
> > seem
> > to handle this problem. I'd like to convert (for
> > example) the following chunk of xml:
> > 
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <XMI xmlns:ABC="org.jason">
> > <XMI.content>
> > <ABC:jason.Smith>
> > <LL/>
> > </ABC:jason.Smith>
> > <Smith/>
> > <XMI content>
> > </XMI>
> > 
> > to this chunk:
> > 
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <XMI xmlns:ABC="org.jason">
> > <XMI.content>
> > <ABC:Smith>
> > <LL/>
> > </ABC:Smith>
> > <Smith/>
> > <XMI content>
> > </XMI>
> > 
> > In other words I want to replace each elament
> named
> > jason.Smith with an identical element (ie not
> affect
> > any of it's children or it's attributes) named
> Smith
> > but only when It occurs in the Namespace ABC. I
> want
> > all other elements in the output file to remain
> > unchanged. I think I need to use the XPATH
> > namespace(
> > ) function in my match expression but I can't
> quite
> > seem to get it to work. Any help with creating
> this
> > stylesheet would be greatly appreciated.  Thanks
> in
> > advance!
> > 
> > -Jason
> > 
> > ps - What would a style sheet look like which
> > created
> > an output xml document identical to the source xml
> > document? 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Send FREE video emails in Yahoo! Mail!
> > http://promo.yahoo.com/videomail/
> > 
> >  XSL-List info and archive: 
> > http://www.mulberrytech.com/xsl/xsl-list
> > 
> > 
> >  XSL-List info and archive: 
> > http://www.mulberrytech.com/xsl/xsl-list
> > 
> 
> Dan,
> 
> Thanks, this solved my problem (as I stated it)
> perfectly.  You're 8 lines of XPATH did what my 50
> couldn't :)  I guess there is a bit of a learning
> curve.  Still, I have one additional problem.  I
> realized that I didn't quite state my problem fully.
> 
> It's not suffiecent that I replace elements named
> ABC:jason.Smith with elements named ABC:Smith, I've
> also got to repace any elements whose names begin
> with
> ABC:jason.Smith the elements whose names begin with
> ABC:Smith while leaving the rest of the element name
> unchanged.
> 
> For example, I've got to make the following changes
> anywhere they occur in the document:
> 
> ABC:jason.Smith       ->   ABC:Smith
> ABC:jason.Smith.foo   ->   ABC:Smith.foo
> 
> I've been playing with the starts-with( ) and
> substring-after( ) functions but I can't get it to
> work.  If there is an easy solution you could share
> with me it would be greatly appreciated.  Thanks in
> advance.
> 
> -Jason
> 
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

 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.