Vreemde tekens in XML/XSL pagina

Pagina: 1
Acties:

  • Barracuda_82
  • Registratie: September 2001
  • Laatst online: 19-12-2024

Barracuda_82

mkTime(), not war!

Topicstarter
Ik heb een pagina waarin ik dmv XSL een lijstje met titels weergeef. Als ik hier speciale tekens in gebruik zie ik het volgende:

Afbeeldingslocatie: http://img208.imageshack.us/img208/3995/gekketekensdlofx3.jpg

Die "Â" wordt dus voor elk speciaal teken toegevoegd. Dat is niet de bedoeling, maar ik krijg het met geen mogelijkheid weg. Ben al uren aan het zoeken geweest hier op GoT en op Google, maar ik kan niets vinden!

De XSL die ik gebruik:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes" />
    <xsl:param name="imgurl" />
    <xsl:param name="lesid" select="//@id" />

    <xsl:template match="/">
        <table border="0" cellpadding="2" cellspacing="0" width="100%" summary="Hoofdstukken">
          <tr><td colspan="5" class="td_head">Hoofdstukken</td></tr>
          
          <xsl:choose>
          
          <xsl:when test="count(//stap) > 0">
                 <xsl:apply-templates />
              </xsl:when>
          <xsl:otherwise>
              <tr><td colspan="5" class="oneven" style="padding: 4px 8px;">Geen hoofdstukken gevonden!</td></tr>
            </xsl:otherwise>
            
         </xsl:choose>
         
        </table>
    </xsl:template>
    <xsl:template match="stap">
       
            <tr class="oneven">
                <td style="padding: 4px 8px; border-bottom: 1px solid #FFFFFF;"><xsl:value-of select="@naam" /></td>
                <td width="11" style="border-bottom: 1px solid #FFFFFF;">
                    <xsl:if test="count(preceding-sibling::stap)">
                        <a href="?action=moveup&amp;chapter_id={@id}&amp;les_id={$lesid}">
                            <img src="{$imgurl}up.gif" border="0" alt="^"/>
                        </a>
                    </xsl:if>
              </td>
              <td width="11" style="border-bottom: 1px solid #FFFFFF;">     
                    <xsl:if test="count(following-sibling::stap)">
                        <a href="?action=movedown&amp;chapter_id={@id}&amp;les_id={$lesid}">
                            <img src="{$imgurl}down.gif" border="0" alt="#" />
                        </a>
                    </xsl:if>
                </td>
                <td width="20" align="center" style="padding: 4px 4px; border-bottom: 1px solid #FFFFFF;">
                    <a href="?action=editchapter&amp;chapter_id={@id}&amp;les_id={$lesid}">
                        <img src="{$imgurl}edit.gif" border="0" alt="[]" />
                    </a>
                </td>
                <td width="15" align="center" style="padding: 4px 4px; border-bottom: 1px solid #FFFFFF;">
                    <a href="?action=deletechapter&amp;chapter_id={@id}&amp;les_id={$lesid}">
                        <img src="{$imgurl}tresj.gif" border="0" alt="[]" />
                    </a>
                </td>
            </tr>
            
    </xsl:template> 
</xsl:stylesheet>

  • truegrit
  • Registratie: Augustus 2004
  • Laatst online: 19-11 23:52
heeft waarschijnlijk te maken met de encoding van het resultaat, of van de xml. Probeer eens met UTF-8

hallo


  • Cyphax
  • Registratie: November 2000
  • Laatst online: 17:59

Cyphax

Moderator LNX
Dit is echt weer zo'n encoding probleem, iets als: de XML is opgeslagen in de ene encoding en de weergave gaat uit van een andere. Zet je de encoding in je XMLbestand?
Misschien heb je hier iets aan: http://www.w3schools.com/xml/xml_encoding.asp

Wat je ook kunt doen om wat te testen is je browser de encoding aanpassen, dat kan met zowel IE als met Fx.

[ Voor 18% gewijzigd door Cyphax op 20-11-2006 12:14 ]

Saved by the buoyancy of citrus


  • Barracuda_82
  • Registratie: September 2001
  • Laatst online: 19-12-2024

Barracuda_82

mkTime(), not war!

Topicstarter
Probleem is dat de XML door een PHP functie wordt gegenereerd, en dat ik geen idee heb hoe ik dus de encoding van dat resultaat aan kan passen...

Dit is de functie die daar voor zorgt (heb ik niet zelf geschreven, maar een collega die er niet meer is):
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public function getLesStructure( $format = "html", $showHidden = true )
    {
        $aRubr = $this->oDb->fetchAssocArr( "blabla", "__object__" ); 
                                             
        $oRubr = $this->xmlDoc->appendChild( $this->xmlDoc->createElement("les") ); 
        
        $oRubr->setAttribute( "id", $this->lesID );     
        $oRubr->setAttribute( "name", utf8_encode($this->getLessonTitle()) );
    
        $this->setActivePage( $this->activeParent );
        $this->getActiveParents( $this->activeParent );
        
        foreach( $aRubr as $rubr )
        {
            $oRubrNode = $oRubr->appendChild( $this->xmlDoc->createElement("stap") ); 
            $oRubrNode->setAttribute( "naam", utf8_encode($rubr->naam) ); 
            $oRubrNode->setAttribute( "id", $rubr->id ); 
            
            //get current(highlighted step)
            if( $this->stepID == $rubr->id ) {
               $oRubrNode->setAttribute( "exp", "true"); 
            }           
            $this->renderMenu( 0, 0, $oRubrNode, $rubr->id );
        }
        return $this->transform( $format );
    }


Edit:
Inmiddels heb ik dit gevonden:
PHP:
1
$this->xmlDoc = new DOMDocument();


En dat heb ik veranderd naar:
PHP:
1
$this->xmlDoc = new DOMDocument('1.0', 'utf-8');


maar dat heeft totaal geen effect.

[ Voor 8% gewijzigd door Barracuda_82 op 20-11-2006 12:36 ]


  • Barracuda_82
  • Registratie: September 2001
  • Laatst online: 19-12-2024

Barracuda_82

mkTime(), not war!

Topicstarter
Ik heb het gevonden!

Ik moest dus wel encoding aan de nieuwe DOMDocument toevoegen, maar daarna weer weghalen in de functie (uft8_encode()).

Wat mij betreft mag dit topic in het archief!

  • Cyphax
  • Registratie: November 2000
  • Laatst online: 17:59

Cyphax

Moderator LNX
Barracuda_82 schreef op maandag 20 november 2006 @ 12:49:
Ik heb het gevonden!

Ik moest dus wel encoding aan de nieuwe DOMDocument toevoegen, maar daarna weer weghalen in de functie (uft8_encode()).

Wat mij betreft mag dit topic in het archief!
Bij deze gearchiveerd. :+

Saved by the buoyancy of citrus

Pagina: 1