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

RE: RE: Retrieving info between two tags.

Subject: RE: RE: Retrieving info between two tags.
From: cknell@xxxxxxxxxx
Date: Thu, 30 Aug 2007 11:50:30 -0400
RE: RE:  Retrieving info between two tags.
This stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:strip-space elements="*" />
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />

    <xsl:template match="/">
      <xsl:value-of select="step1/para[2]/node()[1]" />
    </xsl:template>

</xsl:stylesheet>

When run against this document:

<step1>
	<para>para1<seqlist>
		<item>1</item>
		<item>2</item>
		<item>3</item></seqlist></para>
	<para>Para2<seqlist>
		<item>1</item>
		<item>2</item>
		<item>3</item></seqlist></para>
	<para>para3</para>
</step1>

Produces this output:

<?xml version="1.0" encoding="UTF-8"?>Para2



-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Maxine Pensyl-Johnson <Maxine.Pensyl-Johnson@xxxxxxx>
Sent:     Thu, 30 Aug 2007 08:47:05 -0700
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  RE:  Retrieving info between two tags.

Thank you for the correction. I'll be more aware of my vocabulary.

<xsl:value-of select="/step1/para[2]/node()[1]" />

Outputs nothing.



-----Original Message-----
From: cknell@xxxxxxxxxx [mailto:cknell@xxxxxxxxxx] 
Sent: Thursday, August 30, 2007 8:42 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Retrieving info between two tags.

The XPath expression you need can be written is a number of ways,
depending on the context from which it is called. This will work
anywhere in your stylesheet, but it could be expressed other ways.

<xsl:value-of select="/step1/para[2]/node()[1]" />

P.S.

I realize you are new here, so before someone else gives you a sterner
lecture, let me draw your attention to some vocabulary issues. There was
a very funny "dictionary" posted to this list some months back. I can't
find the link, but the idea was that "tag" was used for so many,
unrelated ideas, that the term has become confusing.

This (<step1>) is a tag. This is another tag (</step1>). Both tags
together, along with all the tags and text in between are properly
called an "element". So when you want to talk about elements, it's best
to avoid the term "tag".

-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Maxine Pensyl-Johnson <Maxine.Pensyl-Johnson@xxxxxxx>
Sent:     Thu, 30 Aug 2007 08:06:05 -0700
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:   Retrieving info between two tags.

Greetings everyone,

I have a situation where I need to define separate out puts for each
para tag within the step1 tag. So I've created a <step1> template and in
it I test the para number and output the correct formatting. For the
first para it outputs the para followed by the seqlist.

The second para's are where I'm having some difficulty. I need pull the
text from the second para into a table row. Then  and pull the item tags
into another row.

So my question is what's the best way to retrieve the non-nested
information in a tag?


XPATH 1.0
SAXON 6.5.5

Example tags:

<step1>
	<para>para1<seqlist>
		<item>1</item>
		<item>2</item>
		<item>3</item></seqlist></para>
	<para>Para2<seqlist>
		<item>1</item>
		<item>2</item>
		<item>3</item></seqlist></para>
	<para>para3</para>
</step1>


In this situation I need to retrieve the text between <para> &
<seqlist>. Originally I tried <xsl:apply-templates select="para[2]". But
that gave me


Para2
	1
	2
	3

The para[2] template match pulled in the seqlist formatting.

So then I tried the value-of select="para[2]" and that gave me

Para2 1 2 3

How can I select and output only what's between <para[2]> and <seqlist>?

XSL:
       <xsl:when test="para[2]">
           <table>
            <tr>
               <td style="PADDING-RIGHT: 2px"><xsl:number
count="//step1[para[2]]" format="1."/></td>
               <td><xsl:value-of select="para"/></td>
            </tr>
            </table>
       </xsl:when>

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.