🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Dariusz Wojtas Thu, 19 Oct 2000 10:38
Pytanie o XPath
#510
Author: Dariusz Wojtas
Date: Thu, 19 Oct 2000 10:38
40 lines
1806 bytes
Czy ktos moglby mi podeslac przyklad wykorzystania funkcji 
	substring( string, number [, number])
w arkuszu .xsl ?

Mam taki plik xml

<pub>
<title>Tytul</title>
<body>
   tekst tekst tekst tekst
   tekst tekst tekst tekst
   tekst tekst tekst tekst
   tekst tekst tekst tekst
</body>
</pub>


i odpowiadajacy arkusz .xsl

                        <xsl:template match="pub">
                            <xsl:apply-templates select="title"/>
                            <xsl:apply-templates select="body"/>
                        </xsl:template>

                        <xsl:template match="pub/title">
		<xsl:apply-templates/>
                        </xsl:template>

                        <xsl:template match="pub/body">
		<xsl:apply-templates/>
                        </xsl:template>
===================

Moim zamiarem jest przycinanie tekstu w body do pewnej ilosci znakow,
i jesli zostal przyciety do dolozenie tam 3 kropek.

Mam spis funkcji XPath, wyglada na to, ze daje sie to zrobic, ale ja
nie umiem tego wykorzystac, brakuje mi przykladu.

	Dariusz Wojtas
Re: Pytanie o XPath
#511
Author: Dariusz Wojtas
Date: Thu, 19 Oct 2000 11:26
25 lines
1525 bytes
Znalazlem odpowiedz :-)

     <xsl:value-of select="substring(//body, 0, 100)"/>

Wytnie pierwsze 100 znakow.

Ale teraz nie wiem jak sprawdzic dlugosc tego ciagu.
Powinno dzialac cos takiego :
     <xsl:value-of select="string-length(//body"/>


lub takiego
    <xsl:variable name="zmienna">
          <xsl:value-of select="string(//body)"/>
    </xsl:variable>
    <xsl:value-of select="string-length($zmienna)"/>


Ale zaden z tych przykladow mi nie dziala.
W drugim przypadku wartosc w zmiennej jest, bo jesli ja probuje
wypisac, to sie to udaje, ale jak sprawdzic dlugosc?
Moze komus uda sie rozwiazac problem?


	Dariusz Wojtas
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads