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

RE: Accessing file properties

Subject: RE: Accessing file properties
From: "Wei, Alice J." <ajwei@xxxxxxxxxxx>
Date: Sat, 26 Jan 2008 22:47:44 -0500
RE:  Accessing file properties
Hi, Sean:

  Sadly, XSLT has no search and replace functions of arguments like Perl. If
you want, you can write a little program in Perl, and tell it to search for
your <file name="WORD_DOC_NAME"> string, and use a substring function to
replace it with your intended file name.

  What you can do, if you do have a lot of WORD_DOC_NAME that you want to
replace at once, you can use this little recipe:

fn:replace(string,pattern,replace)
Returns a string that is created by replacing the given pattern with the
replace argument

Example: replace("Bella Italia", "l", "*")
Result: 'Be**a Ita*ia'
Example: replace("Bella Italia", "l", "")
Result: 'Bea Itaia'

This is taken from the W3 Schools site, or you can look at
http://www.xsltfunctions.com/xsl/fn_replace.html
There are also some discussion on replace() on Michael Kay's XPath.

<xsl:template match="file">
<xsl:choose>
<xsl:when test="contains(@name,'WORD_FILE_DOC')">
<xsl:value-of select="replace(@name,'FILE','NEW')">
</xsl:when>
<xsl:otherwise>
<xsl:value-of select=".">
</xsl:otherwise>
</xsl:template>

Good luck!

 ======================================================
 Alice Wei
 MIS 2008
 School of Library and Information Science
 Indiana University Bloomington
 ajwei@xxxxxxxxxxx


-----Original Message-----
From: Sean Tiley [mailto:sean.tiley@xxxxxxxxx]
Sent: Saturday, January 26, 2008 9:56 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Accessing file properties

Hi Alice,
Yes, I want to output the document name in my resulting xml file which
looks like the following

<testresults>
    <file name="WORD_DOC_NAME">
        <testruns>
            <testrun>
                <test case="TC-01" result="FAIL" date="2008-01-25"
bugid="123"/>
                <test case="TC-02" result="FAIL" date="2008-01-25"
bugid="456"/>
                <test case="TC-03" result="FAIL" date="2008-01-25"
bugid="789"/>
                <test case="TC-04" result="PASS" date="2008-01-25"/>
            </testrun>
            <testrun>
                <test case="TC-01" result="PASS" date="2008-01-26"/>
                <test case="TC-02" result="PASS" date="2008-01-26"/>
                <test case="TC-03" result="FAIL" date="2008-01-26"
bugid="790"/>
                <test case="TC-04" result="PASS" date="2008-01-26"/>
                <test case="TC-05" result="PASS" date="2008-01-26"/>
                <test case="TC-06" result="FAIL" date="2008-01-26"
bugid="791"/>
            </testrun>
        </testruns>
    </file>
    <file/>
    ...
</testresults>


I wish to replace "WORD_DOC_NAME" with the file name

Thanks
Sean

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.