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

Re: regex and tab-delimited text

Subject: Re: regex and tab-delimited text
From: Terry Ofner <tofner@xxxxxxxxxxx>
Date: Thu, 17 Jan 2008 17:19:27 -0500
Re:  regex and tab-delimited text
Okay. So then my stylesheet needs to be adjusted somehow.

Here is what I am trying to do.

Snippet of xml input:
<test>
<question>	2	<stem>As used in the sentence below, what is the
denotation of the word <i>mutt</i>?</stem>
<display>&#8220;What is that mutt doing in our yard?&#8221; asked
Dad.</display>
<choices>
	A	animal
	B	dog
	C	creature
	D	pet
</choices>
</question>
</test>

I am trying to wrap each answer choice with the corresponding <choice-
x> element:

<choices>
	<choice-a>animal</choice-a>
	<choice-b>dog</choice-b>
	<choice-c>creature</choice-c>
	<choice-d>pet</choice-d>
</choices>

With my current stylesheet I am just trying to get choice A to work:

<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:template  match="/test/question/choices">
                <choice-a><xsl:copy-of select="replace(.,'\tA\t(.*?)
\r','$1')"/></choice-a>
 </xsl:template>
</xsl:stylesheet>


Current output:


<question> 2       <stem>As used in the sentence below, what is the
denotation of the word <i>mutt</i>?</stem>
      <display>What is that mutt doing in our yard? asked Dad.</
display>
<choice-a>
        A       animal
        B       dog
        C       creature
        D       pet</choice-a>
   </question>


Thanks in advance for any tips.


Terry

On Jan 17, 2008, at 3:48 PM, Jesper Tverskov wrote:

On 1/17/08, Terry Ofner wrote:
My question has to do with the fact that \t does not seem to work...

I should work. It is part of REGEX in XSLT building on REGEX in XML Schema: http://www.w3.org/TR/xmlschema-2/#regexs

Cheers,
Jesper Tverskov
http://www.xmlplease.com

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.