xsl-list
[Top] [All Lists]

RE: xml nodes with spaces (at start, end, or just spaces) not showing correctly with xsl

2004-06-17 11:59:43
The most important thing to take away from my message is that the node defined 
here:

<Text>The quick&lt;deleted&gt; brownfox
&lt;/deleted&gt;&lt;inserted&gt; brown fox &lt;/inserted&gt;jumped over
the fat lazy&lt;inserted&gt; &lt;/inserted&gt;dog.</Text>

has one single child text node. When you escape the contents of the element you 
are telling the xml parser to treat the whole thing as text, which means that 
it does not get parsed into nodes so there are no inserted nodes, or deleted 
nodes, only the text.

I used Saxon to transform the xml/xsl that you sent and got this result:

<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <title>OSR report 1.1</title>
      <LINK REL="stylesheet" HREF="reports/css/mxml.css" TYPE="text/css">
   </head>
   <body><font size="3" color="#000000">Learning
         Point</font><hr>

          <b>Text Chunk</b><br><font size="2" color="#FF0000"><b><Script src="re
ports/js/row.js"></Script></b></font><br><font size="2" color="#0000FF">Text Row
:</font><br>----- On Screen Text -----<br>

        <br><br></body>
</html>

Which doesn't contain the output that you sent in your previous message. What 
processor are you using? Also, when sending examples you should try and trim it 
to the smallest running example that shows your problem.

Josh


-----Original Message-----
From: Andrew Madigan [mailto:Andrew_Madigan(_at_)skillsoft(_dot_)com]
Sent: Thursday, June 17, 2004 3:19 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] xml nodes with spaces (at start, end, or just spaces)
not showing correctly with xsl


Hi Josh,

I keep getting failure notices, so I guess the file is too large so I
have striped out some of the xsl that does not deal with the same issue.

Here is a sample XML:
 <?xml version="1.0" encoding="UTF-8"?>

<LearningObject version="6">
  <LearningObjectProperties>
    <FileName/>
    <Duration/>
    <ObjectType>Flash</ObjectType>
    <LearningObjective>After completing this topic, you should be able
to </LearningObjective>
    <LearningPathCode/>
    <LearningPathTitle/>
    <ModuleCode/>
    <ModuleTitle/>
    <LearningEventCode/>
    <LearningEventTitle/>
    <LearningObjectCode/>
    <LearningObjectTitle/>
  </LearningObjectProperties>
  <LearningPoint type="conceptual" audioenabled="false">
    <Title/>
    <Slide type="textual">
      <Click type="text">
        <Text>The quick&lt;deleted&gt; brownfox
&lt;/deleted&gt;&lt;inserted&gt; brown fox &lt;/inserted&gt;jumped over
the fat lazy&lt;inserted&gt; &lt;/inserted&gt;dog.</Text>
      </Click>
    </Slide>
    <ObjectId></ObjectId>
  </LearningPoint>
</LearningObject>


And the striped down XSL:
<?xml version="1.0" encoding="ISO-8859-1"?> 

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>


        <xsl:template match="LearningObject" >
        <xsl:for-each select="LearningPoint">
                <html>
                <head>
                <title>OSR report 1.1</title>
                <LINK REL="stylesheet" HREF="reports/css/mxml.css"
TYPE="text/css"/>
                </head><body>
                <font size="3" color="#000000">Learning
Point</font><hr/>
                <xsl:for-each select="Title[deleted]">
                   
                    Title (Deletion):
                    <br/>
                    <xsl:apply-templates/>
                   
                  </xsl:for-each>
                
                  <xsl:for-each select="Title[inserted]">
                   
                    Title (Insertion):
                    <br/>
                    <xsl:apply-templates/>
                   
                </xsl:for-each>
                <xsl:apply-templates/>
                <br/>
                <br/>
                </body>
                </html>
                </xsl:for-each>
        </xsl:template>






 <xsl:template match="deleted"/>
 
 <xsl:template match="b">
 <b>
 <xsl:apply-templates/>
 </b>
 </xsl:template>
 
 
 
 
 <xsl:template match="p">
  <p/>
  <xsl:apply-templates/>
 </xsl:template>
 
 <xsl:template match="inserted">

   <xsl:apply-templates/>
 </xsl:template>
  
  <xsl:template match="br">
   <br/>
   <xsl:apply-templates/>
 </xsl:template>
 
 
 
 <xsl:template match="i">
  <i>
  <xsl:apply-templates/>
  </i>
 </xsl:template>
 
 <xsl:template match="font[(_at_)face='Courier New, Courier, mono']">
   <font face='Courier New, Courier, mono'>
   <xsl:apply-templates/>
   </font>
 </xsl:template>
 
 
 
 
 
<xsl:template match="Reply"/>

<xsl:template match="Slide[(_at_)type='textual']">

<b>Text Chunk</b>
<xsl:for-each select="Click[(_at_)type='text']">
<br/><font size="2" color="#FF0000">
<b><Script src="reports/js/row.js"/>
</b></font>
<br/><font size="2" color="#0000FF">Text Row:</font>
<br/>----- On Screen Text -----<br/>

  <xsl:for-each select="Text[deleted]">
  
    Deletion:
    <br/>
    <xsl:apply-templates/>
   
  </xsl:for-each>

  <xsl:for-each select="Text[inserted]">
   
    Insertion:
    <br/>
    <xsl:apply-templates/>
   
  </xsl:for-each>


<xsl:for-each select="Launch[(_at_)type='animation']">
----- Animation -----<br/>
<xsl:for-each select="Prompt/Content[deleted]">
   
    Prompt (Deletion):
    <br/>
    <xsl:apply-templates/>
   
  </xsl:for-each>
  <xsl:for-each select="Prompt/Content[inserted]">
   
    Prompt (Insertion):
    <br/>
    <xsl:apply-templates/>

  </xsl:for-each>
</xsl:for-each>

<xsl:for-each select="Launch[(_at_)type='windowlaunch']">
----- Launch Window -----<br/>
<xsl:for-each select="Prompt/Content[deleted]">
   
    Prompt (Deletion):
    <br/>
    <xsl:apply-templates/>
  
  </xsl:for-each>

  <xsl:for-each select="Prompt/Content[inserted]">
   
    Prompt (Insertion):
    <br/>
    <xsl:apply-templates/>

  </xsl:for-each>

</xsl:for-each>




<xsl:for-each select="Code[deleted]">
   <div id="alttext">
    Code (Deletion):
    <br/>
    <xsl:apply-templates/>
   </div>
  </xsl:for-each>

  <xsl:for-each select="Code[inserted]">
   <div id="alttext">
    Code (Insertion):
    <br/>
    <xsl:apply-templates/>
   </div>
  </xsl:for-each>


<xsl:for-each select="Syntax[deleted]">
   <div id="alttext">
    Syntax (Deletion):
    <br/>
    <xsl:apply-templates/>
   </div>
  </xsl:for-each>

  <xsl:for-each select="Syntax[inserted]">
   <div id="alttext">
    Syntax (Insertion):
    <br/>
    <xsl:apply-templates/>
   </div>
  </xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>




Thanks!
Andy

-----Original Message-----
From: Josh Canfield [mailto:Josh(_dot_)Canfield(_at_)plumtree(_dot_)com] 
Sent: 16 June 2004 18:15
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] xml nodes with spaces (at start, end, or just spaces)
not showing correctly with xsl

You have escaped the text inside of your Text element so that the XML
parser will treat it like text, therefore there are no <inserted> or
<deleted> elements, only a block of text.

Why are you escaping the contents of the <Text> element?

Also, your output is not what I would expect. I would expect to see the
"&lt;inserted&gt" make it into the output. Can you show a complete
template that outputs as you have described?

Josh


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



<Prev in Thread] Current Thread [Next in Thread>