Toon posts:

XML / XSL div positionering probleem

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik heb de volgende code voor xml

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" ?>
<?xml-stylesheet type='text/xsl' href='news.xsl'?>
  <page xmlns="http://www.test.nl"> 
    <texts>
        <text> 
            <description><html xmlns="http://www.w3.org/1999/xhtml">dit is een beetje<br/> blah blah
               dit is een beetje blah blah
               dit is een beetje blah blah <strong>dit is een beetje blah blah</strong></html>
             </description>
            <width>200</width>
            <height>100</height>
            <xpos>350</xpos>
            <ypos>250</ypos>      
        </text>
    </texts>
  </page>


Mijn XSL ziet er als volgt uit
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"
            xmlns:n="http://www.test.nl"
           xmlns:html="http://www.w3.org/1999/xhtml"
              xmlns="http://www.w3.org/1999/xhtml">

    <xsl:output method="xml" indent="yes"/> 

    <xsl:template match="n:page/texts">
      <html>
        <head>
            <title>Test pagina</title>
        </head>

        <body>
            <xsl:apply-templates select="n:text"/>
        </body>
      </html>
    </xsl:template>

    <xsl:template match="html:*">
      <xsl:element name="{name(.)}" namespace="http://www.w3.org/1999/xhtml">
        <xsl:for-each select="@*">
            <xsl:attribute name="{name(.)}">
              <xsl:value-of select="."/>
            </xsl:attribute>
        </xsl:for-each>
        <xsl:apply-templates/>
      </xsl:element>
    </xsl:template>

    <xsl:template match="n:text">      
    <div>
        <xsl:attribute name="style">
            position:absolute; 
            width:<xsl:value-of select="n:width" />px; 
            height:<xsl:value-of select="n:height" />px; 
            left:<xsl:value-of select="n:xpos" />px;
            top:<xsl:value-of select="n:ypos" />px; 
            overflow:auto;
            border:1px dashed;
        </xsl:attribute>
        
        <table border="0">
            <tr>
                <td width="100%" height="100%">
                    <xsl:apply-templates select="n:description"/>
                </td>
            </tr>
        </table>            
    </div>    
          
    </xsl:template>    
</xsl:stylesheet>


Het probleem is nu dat de div niet op de juiste positie wordt weergegeven.
De div moet op left: 350 top: 250 komen te staan.
Voordat ik gebruik ging maken van namespaces (voor het correct weergeven van HTML tags) werkte het prima.

[ Voor 44% gewijzigd door Verwijderd op 12-03-2004 16:43 ]


Verwijderd

Topicstarter
Wanneer ik de boel server-side parse, werkt het wel goed.
Als ik de XML file in Mozilla 1.6 niet

Misschien een bug in mozilla?

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06-2025

drm

f0pc0dert

Probeer eens om ook een doctype-system en doctype-public attribuut in je xsl:output element te zetten.

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz