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

Re: xpath query

Subject: Re: xpath query
From: "Sean Tiley" <sean.tiley@xxxxxxxxx>
Date: Sat, 19 Jan 2008 11:38:32 -0500
Re:  xpath query
Thank you all.

I was thinking last night, typically I just output an html file to see
the results of my transformation.
Then I thought what if I just wanted to process the original xml file,
replace the apply="1" with apply="true" and write the results to
another xml file
I read elsewhere in the archives about the identity template and the
suggestion is basically the following (to just replicate the original
xml)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes"/>
   <xsl:template match="@* | node()">
       <xsl:copy>
           <xsl:apply-templates select="@* | node()"/>
       </xsl:copy>
   </xsl:template>
</xsl:stylesheet>

Which works as advertised.
I understand that I can create another template to match what ever I
like to futrher refine the output like this

 <xsl:template match="@apply">
       <xsl:attribute name="apply">
           <xsl:value-of select="replace(., '1', 'true')"/>
       </xsl:attribute>
   </xsl:template>

So far so good.
I have 2 questions though.
1) - In the first template that copies the original xml, the
expression select="@* | node()" What is this saying?
I read it is another way of phrasing this select="attribute() |
element() | text() | comment() | processing-instruction()" (which
seems much clearer)
Either expression does what I want, but I am trying to map the first
expression "@* | node()" onto the latter.
I am pretty sure the @* means all attributes?  If this is the case how
does "node()" translate to "element() | text() | comment() |
processing-instruction()"?

2) - Also related to the first template. Why do I need the
<xsl:template match="@* | node()"> and
<xsl:apply-templates select="@* | node()"/> in the <xsl:copy/> tag?
I would have thought in the template match "/" would have sufficed.
(When I try that, I just get the values from the nodes).

Also in the thread Abel stated
>I think many people find this at first confusing: when do you get a node
>set, when do you get one node, when do you get a sequence or a sequence
>of nodes, when do you need apply-templates, when for-each or
>for-each-group etc etc. Getting it straight is vital for working with
>XSLT without frustration.

Do you know of any resources, either online or in print that explain
these concepts well with good examples?  I would really like to make
this confusion
a thing of the past for myself.
Thanks in advance
Sean

On Jan 19, 2008 8:21 AM, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
> Sean Tiley wrote:
> > Hi Abel,
> > No I am not the same person. Why did you think that?
> >
>
> The first part of the OP's name is 'Sen', yours is "Sean". Also, it
> happens sometimes that people use different email addresses to anonymize
> their posts, but sometimes forget it and send from their other address.
> And of course, companies may share addresses with people through groups
> (but then it's not the same p).
>
> > I was reading the thread and was trying to fully understand the
> > requirement and solutions provided. I used the original XML to play
> > with creating my stylesheets to see what I could do with it.
> >
>
> That's very good, that was the way I learned XSLT: reading from the list
> and trying to understand what was posted.
>
> > Did I do something incorrect when I asked my questions in the same
> > thread?  Should I have posted a new message.  Please tell me as I am
> > new to this list and dont want to make a bad impression.
> >
>
> No and not necessarily, but Tommie already explained you that ;)
> I was just a bit puzzled by your follow-up questions and didn't see
> something like "I read this thread and was wondering about...". So it
> "sounded" as if it was the OP (Original Poster) asking follow-ups...
>
> > I do appreciate your comments on my questions, they certainly help me
> > get all of this straight in my head.
> >
>
> Glad to have been of help. Ask anytime, this is a lively list and we're
> here to help ;)
>
>
> Cheers,
> -- Abel Braaksma
>
>

-- 
Sean Tiley
sean.tiley@xxxxxxxxx

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.