Announcement

Collapse
No announcement yet.

prüfe für jedes Tag, ob es mit A anfängt und zähle die summe

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • prüfe für jedes Tag, ob es mit A anfängt und zähle die summe

    manno das kann doch nicht so schwer sein. Ich bekomme es einfach nicht hin.

    XML-Datei:

    Code:
    <A>
    <page number="1">
    		<B>
    			<C>
    				<text left="79" top="1422" width="62" height="41">a</text>
    				<NEW_LINE>
    					<text left="468" top="1475" width="125" height="46">e</text>
    					<text left="2329" top="1475" width="57" height="46">h</text>
    					<text left="618" top="1476" width="267" height="41">i</text>
    					<text left="224" top="1555" width="119" height="32">j</text>
    					<text left="477" top="1555" width="301" height="32">k</text>
    					<text left="224" top="1755" width="119" height="32">j</text>
    					<text left="224" top="1955" width="119" height="32">j</text>
    				</NEW_LINE>
    			</C>
    		</B>
    	</page>
    <page number="2">
    		<B>
    			<C>
    				<text left="79" top="1422" width="62" height="41">a</text>
    				<NEW_LINE>
    					<text left="468" top="1475" width="125" height="46">e</text>
    					<text left="2329" top="1475" width="57" height="46">h</text>
    					<text left="618" top="1476" width="267" height="41">i</text>
    					<text left="224" top="1555" width="119" height="32">j</text>
    					<text left="477" top="1555" width="301" height="32">k</text>
    				</NEW_LINE>
    			</C>
    		</B>
    	</page>
    </A>
    Mit dem Code:

    text[@left&gt;220 and @left&lt;473]
    bekomme ich alles was zwischen diesen left Koordinaten ist.
    Aber da drinnen sind Tags enthalten, die ich nicht brauche.

    Deshalb wollte ich die Funktion contains oder starts-with benutzen.

    In Worten:

    Prüfe für alle A/page/B/C/NEW_LINE/text[@left&gt;220 and @left&lt;473]
    wenn es Elemente darin gibt, die mit j anfangen oder ein j enthalten, dann lass die darin und alles andere weg. Danach zähle wieviele j Elemente es gibt.

    Code:
     <xslt:key name="k1" match="text" use="."/>
    
    <xslt:template match="A/page/B/C/NEW_LINE/text">
    <xslt:variable name="juhu">
    						<xslt:for-each select="text[@left&gt;220 and @left&lt;473][generate-id() = generate-id(key('k1', .)[1])]">
    <xslt:if test="starts-with(.,'j'")>
    				 <xslt:value-of select="."/>
    </xslt:if>
            <xslt:if test="position() != last()"><xslt:text> </xslt:text></xslt:if>
    					</xslt:for-each>
    </juhu>
    <xslt:value-of select="count(tokenize($juhu))"/>
    Mein Code funktioniert nicht.
    Kann wer da helfen?
    Vielen Dank,
    Tamer
    Zuletzt editiert von Tamer; 06.12.2009, 04:03.
Working...
X