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

RE: How to capture text?

Subject: RE: How to capture text?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 18 Aug 2005 09:36:47 +0100
capture text field
As far as I can see you are trying to get all the text nodes other than
whitespace text nodes and text:user-field-get text nodes, so I would do:

<xsl:strip-space elements="*"/>

<xsl:template match="text:user-field-get"/>

<xsl:template match="text()">
  <aid><xsl:value-of select="normalize-space(.)"/></aid>
</xsl:template>


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

 

> -----Original Message-----
> From: aaron apigo [mailto:aaronjose_apigo2001@xxxxxxxxx] 
> Sent: 18 August 2005 06:31
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  How to capture text?
> 
> Hi,
>   I'm a beginner in XSLT, i want to transform this
> piece of XML:
> 
> <text:p>
> <text:user-field-get
> text:name="aid">ArticleId</text:user-field-get>
> <text:span>1423</text:span>
> </text:p>
> <text:p>
> <text:span>
> <text:user-field-get
> text:name="aid">ArticleId</text:user-field-get>
> </text:span>
> <text:span>1423</text:span>
> </text:p>
> <text:p>
> <text:span>
> <text:user-field-get
> text:name="aid">ArticleId</text:user-field-get>
> </text:span>1423
> </text:p>
> <text:p>
> <text:user-field-get
> text:name="aid">ArticleId</text:user-field-get>1423
> </text:p>
> 
> output:
> <aid>1423</aid>
> <aid>1423</aid>
> <aid>1423</aid>
> <aid>1423</aid>
> 
> if you noticed all the data are the same, what I'm
> trying to do is to check all the possible scenario
> that might happen in the XML. Sometimes
> <text:user-field-get text:name="aid"> appears inside
> the <text:span> sometimes not, and same with the text,
> sometimes it appears inside the <text:span>, sometimes
> not. So my XSLT should handle all those scenario.
> 
> with my XSLT,
> 
>     <xsl:template match="text:p">
>         <xsl:apply-templates
> select="text:span/text:user-field-get|text:user-field-get"/>
>     </xsl:template>
>     
>     <xsl:template
> match="text:span/text:user-field-get">
>             <xsl:element name="{@text:name}">
> 	                <xsl:apply-templates
> select="parent::text:span/following-sibling::*[1][self::text:s
> pan/text()]"/>
>         	        <xsl:apply-templates
> select="following-sibling::text()"/>
>             </xsl:element>
>     </xsl:template>
>     
>     <xsl:template match="text:user-field-get">
>         <xsl:element name="{@text:name}">
>             <xsl:apply-templates
> select="following-sibling::text:span/text()"/>	
>         </xsl:element>
>     </xsl:template>    
> 
> my output,
> 
> <aid>1423</aid>
> <aid>1423</aid>
> <aid></aid>
> <aid></aid>
> 
> I can't handle the text that are not inside the
> <text:span>
> 
> Please help.
> 
> regards.
> aaron
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 		
> ____________________________________________________
> Start your day with Yahoo! - make it your home page 
> http://www.yahoo.com/r/hs 

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.