Bug 742 - [Chameleon - doc builder] how to handle <cr> during reprocessing of widget doc
: [Chameleon - doc builder] how to handle <cr> during reprocessing of widget doc
Status: RESOLVED FIXED
: Chameleon
AutoDoc
: 1.99
: PC Windows 2000
: P1 normal
: 2.0 RC 1
Assigned To:
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2004-10-19 17:38 by
Modified: 2004-10-21 14:20 (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2004-10-19 17:38:22
It is very important that when doc_builder process the xml template that it does
not remove <cr> within elements. This is particularly important for any
<cham:code></cham:code> in the xlst these elements are inserted between
<pre></pre> HTML tags.

I tried inserting &#013; the decimal ascii code into the document before xml
reprocess. What happened to the new xml document is that the ascii code was
replaced by actual <cr> the code was removed. Which means when reprocessed again
the content between the element will be placed all on one line. The <cr> are
removed.
------- Comment #1 From 2004-10-20 07:48:43 -------
Chris, I think that XML ignores whitespace as a general rule.  Since we are
using the xml parser that is built into php, I am not sure we can change how it
works.  I believe that if you want to preserve <cr> then you will need to use
the CDATA syntax.

Bill, there may be an option for the xml parser regarding whitespace, you should
check that first.
------- Comment #2 From 2004-10-20 08:41:59 -------
Looking at this one now.
------- Comment #3 From 2004-10-20 10:33:54 -------
Ok, it appears the only way to make this work properly is to use CDATA.  
i.e.
<![CDATA[
      <bob test="1"
      	att1="1"
      	att2="2">
      	<next>level</next>
      </bob>
]]>

This works very well with the Help Viewer.  Unfortunately the CDATA tags get
blown away by the XML parser in PHP4.  This problem sounds like it is fixed in
PHP5.  No help there unless we are going to PHP5.........Paul?  ;)

Talked with Chris.  It appears that the XSLT can handle this by defining a few
new rules.  Assigning to him.
------- Comment #4 From 2004-10-20 11:14:37 -------
My proposal to this issue after thinking about it. Is to define a child schema
for <cham:code></cham:code>. Here is the change to the schema:

<xs:complexType name="CodeValue">
 <xs:choice>
  <xs:element name="line" type="xs:string" maxOccurs="unbounded" minOccurs="1"/>
  <xs:element name="comment" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>
  <xs:element name="code" type="cham:CodeValue" maxOccurs="unbounded"
minOccurs="0"/>
 </xs:choice>
</xs:complexType>	

I will then modify the xslt to define the <cr> with this ascii decimal code &#013;. 

I will let you know how this works out shortly.
------- Comment #5 From 2004-10-21 14:20:02 -------
Ok after much effort trying to be the most optimal method to define <cr> and
having issues with the slt translator, and then the css file I got it to work. :)

<xs:complexType name="CodeLine">
 <xs:sequence>
  <xs:element name="line" type="xs:string" maxOccurs="unbounded"/>
 </xs:sequence>
 <xs:attribute name="bold" type="xs:boolean" use="optional" default="false"/>
</xs:complexType>

within example and tag elements had to define <cham:code> as:

<xs:element name="code" maxOccurs="unbounded">
 <xs:complexType>
  <xs:sequence>
   <xs:element name="codeblock" type="cham:CodeLine" maxOccurs="unbounded"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>

In the xslt's it the code section was defined as followes:

<!-- ~~~~~~~~~~~ -->
<!-- Code Section -->
<!-- ~~~~~~~~~~~ -->
<pre class="CodePreview">
 <xsl:for-each select="cham:code">
  <xsl:for-each select="cham:codeblock">
   <xsl:for-each select="cham:line">
    <xsl:if test="../@bold =&quot;false&quot;">
     <xsl:apply-templates /><br /></xsl:if>
   </xsl:for-each>
   <xsl:for-each select="cham:line">
    <xsl:if test="../@bold =&quot;true&quot;">
     <span class="CodeRequired"><xsl:apply-templates /></span><br /></xsl:if>
   </xsl:for-each>                      
  </xsl:for-each>
 </xsl:for-each>
</pre>

You can currently view these changes with only the MapSize.en-ca.doc.xml since
it is currently the only valid doc with the new schema. I will be updateing
others shortly.