xsl-list
[Top] [All Lists]

Re: [xsl] regex and tab-delimited text

2008-01-17 15:20:04
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>