[xsl] Please help. fixing whitespace problem. total xsl Newbie

Subject: [xsl] Please help. fixing whitespace problem. total xsl Newbie
From: "Stacey Levine" <Stacey.Levine@xxxxxxxxxxxxxx>
Date: Fri, 5 Mar 2004 21:28:27 -0500
Ok.. First.. I am a total XSL newbie. On the other hand, I only have this
one problem that I need to fix.. Here is the nutshell
I have a web page that returns XML to an XSL stylesheet. The XSL should (and
does) generate a document that is opened in Word.  The problem is that there
is a summary details section.  The data more often than not has carriage
returns in it.  I need those returns to come over into the word document. 
Unfortunately, these CR?s get erased.  I know that the problem is in the
section :

<p  style="text-align:left; "><u>INVESTIGATION DETAILS</u><br/> <br/> </p>
  <p  style="text-align:left; text-align:justify;"><xsl:value-of
select="@summary_details" /></p>

If I could replace the carriage returns with (  <p  style="text-align:left;
text-align:justify;">DATAHERE</p>) everything would be fine.  I am at a
loss.  I am included the stylesheet below.. and XML that gets sent to it. 
Thanks for helping out a very stuck and very frustrated newbie.

STYLESHEET------------------------------------------------------------------
------------------------------------
<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"; version="1.0">

  <xsl:template match='/'>
   
    <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="root" >
    
    <p style="text-align:left; FONT-SIZE: 16px;">
      <br/> <br/> <br/> <br/>
      <b>INVESTIGATIVE FINDINGS</b>
      <br/> <br/> <br/> <br/>
      <b>DATE:</b><xsl:if
test="finding/@submit_for_review"><xsl:eval>formatDt(this.selectSingleNode('
finding').getAttribute('create_date'))</xsl:eval>
        </xsl:if>
      <br/> <br/>  <br/> <br/>
      <b>CLIENT:</b><xsl:value-of select="finding/@assignor_nm" /><br/> 
      <b>COMPANY:</b><xsl:value-of select="finding/@client_name" /><br/>
      <b>ADDRESS:</b><xsl:value-of select="finding/@assignor_address1" />,  
<xsl:value-of select="finding/@assignor_city" />,  <xsl:value-of
select="finding/@assignor_state" />, <xsl:value-of
select="finding/@assignor_zip" /> <br/> 
      
     
      <br/><br/>
      <xsl:apply-templates select="finding/patient"/>
     </p>   
     <br/><br/>
       <xsl:apply-templates select="finding"/>
        
       <p style="text-align:left;">Sincerely,<br/><br/> <br/>  <br/> <br/>
       John Smith<br/>
       <xsl:value-of select="finding/@investigator_initials" />

       </p>
                        
  </xsl:template>

  <xsl:template match="patient">
    
   <b>CLAIMANT: </b><xsl:value-of select="@patient_nm" /><br/> 
     
   <b>PHYSICAL ADDRESS: </b><xsl:value-of select="@patient_address1" />,  
<xsl:value-of select="@patient_city" />,  <xsl:value-of
select="@patient_state" />, <xsl:value-of select="@patient_zip" /><br/>  
   <b>SOCIAL SECURITY #:</b> <xsl:if test="@ssn">
      
<xsl:eval>formatNumber(this.getAttribute('ssn'),'#########000-00-0000')
</xsl:eval></xsl:if>
    <br/>
       
     
      <b>DATE OF BIRTH:</b><xsl:choose>
      <xsl:when test="@birthdate">
          <xsl:eval>formatDt(this.getAttribute('birthdate')) </xsl:eval>
        </xsl:when>
        <xsl:otherwise> N/A </xsl:otherwise>
      </xsl:choose>
      <br/><br/><br/> 
      <b>CLIENT FILE #: </b><xsl:value-of select="@external_ref_num" />
<br/>
      <b>INJURY:</b><xsl:value-of select="@patient_injury_type" /> <br/>
      <b>DATE OF INJURY: </b>
        <xsl:if test="@injury_dt">
          <xsl:eval>formatDt(this.getAttribute('injury_dt')) </xsl:eval>
        </xsl:if>
       <br/><br/> <br/>   
       <b>CORE FILE #: </b><xsl:value-of select="case/@file_number" /><br/> 
       <b>ENCLOSURES: </b>
         <xsl:choose>
           <xsl:when test="../@finding_enclosures">
             <xsl:value-of select="../@finding_enclosures" />
           </xsl:when>
           <xsl:otherwise></xsl:otherwise> NONE
         </xsl:choose>
        <br/><br/> <br/> 
    </xsl:template>
<xsl:template match="finding">
            
  <p  style="text-align:left;"><u>ASSIGNMENT</u> <br/> <br/></p> 
  <p  style="text-align:left; text-align:justify;"><xsl:value-of
select="@assignment" />   </p> 
 
  <p  style="text-align:left; "><u>SUMMARY OF FINDINGS</u> <br/> <br/> </p>
  <p  style="text-align:left; text-align:justify;"><xsl:value-of
select="@summary" /></p> 

  <p  style="text-align:left; "><u>PRELIMINARY INVESTIGATION</u><br/> <br/> 
</p>
  <p  style="text-align:left; text-align:justify;"><xsl:value-of
select="@preliminary_investigation" />    </p>
  <p  style="text-align:left; "><u>INVESTIGATION DETAILS</u><br/> <br/> </p>
  <p  style="text-align:left; text-align:justify;"><xsl:value-of
select="@summary_details" /></p>

  <p  style="text-align:left; "><u>RECOMMENDATIONS</u><br/> <br/></p>
  <p  style="text-align:left; text-align:justify;">     <xsl:value-of
select="@recommendations" />
    </p>
  
</xsl:template>


<xsl:script><![CDATA[
   
    function formatText(val)
    {
// return val;
   var re = /\n/g
return val.replace(re,'<br/>');

    }
    function formatDt(val)
    {
       if (val == '') 
       {
        var curDate = new Date();
                        
                val = (curDate.getMonth()+1 )+ "/" + curDate.getDate() + "/"
+ curDate.getYear();
        return val
       }
      
       var xmlDoc = new ActiveXObject("microsoft.xmldom"); 
       xmlDoc.loadXML('<root xmlns:xsl="http://www.w3.org/TR/WD-xsl";
xmlns:dt="urn:schemas-microsoft-com:datatypes"><Date dt:dt="datetime">' +
val +'</Date></root>');
     
        var newElem = xmlDoc.selectSingleNode("root/Date");
        return formatDate(newElem.nodeTypedValue, "M/d/yy");
    }
    function formatPhoneNumber(val) {
      
      if ( val != "" )
      {
       var stripped = val.replace(/[\(\)\.\-\ ]/g, ''); 
       if ( isNaN(stripped)) return  val ;
         return formatNumber(stripped, "(###) ###-####");
      }
    }
  
  ]]></xsl:script>
</xsl:stylesheet>

XML DATA

    
<root><finding finding_id="19" summary="The investigation was conducted from
18 July to 4 August 2002, with physical surveillance performed on 18 July, 3
and 4 August 2002.  The claimant was not observed during the investigation.
" create_date="2003-03-04T12:40:26.967" update_info="
" assignment="On 11 July 2002, the client requested two days of surveillance
to be conducted on John Smith, hereafter referred to as the claimant to
document her level of activity.
" preliminary_investigation="On 18 July 2002, the investigator conducted
computer research and telephone inquiries in an effort to verify the
claimant?s information as provided by the client.  Initial inquiries
revealed that the claimant had recently moved and resided with her sister in
Lithonia, Georgia.  However, the exact address could not be obtained.  The
claimant continued to have relatives at the file address, and the claimant
was expected to arrive there later that day at no specified time.  No
further information was available regarding the claimant at that time.
" summary_details="On Thursday, 18 July 2002, the investigator arrived in
the vicinity of the file address at 12:00 p.m.  Upon arrival, several
vehicles were observed parked outside the residence.  Inquiries revealed the
claimant was not yet present within the residence and a stationary
surveillance position was established to observe the front of the
residence.  

Throughout the day, no one fitting the description of the claimant was
observed arriving at the residence.  At 8:00 p.m., telephone inquiries
revealed the claimant had canceled her plans to visit that day, but might
arrive during one of the following weekend days.  Surveillance was suspended
at this time.

On Saturday, 3 August 2002, the investigator returned to the vicinity of the
file address, arriving at 3:30 p.m.  Upon arrival, several vehicles were
observed parked outside the residence and no activity was noted.  Telephone
inquiries revealed that the claimant was expected to arrive at the file
address either that evening or early the next morning.  A stationary
surveillance position was re-established in the area.

No one fitting the description of the claimant was observed arriving at the
residence.  Telephone inquiries were unable to locate the claimant and
surveillance was suspended at 8:00 p.m.

On Sunday, 4 August 2002, the investigator returned to the vicinity of the
file address, arriving at 8:00 a.m.  Upon arrival several vehicles were
observed present and no activity was noted.  A stationary surveillance
position was re-established in the area.  

At 12:00 p.m., telephone inquiries revealed the claimant no longer had plans
to arrive at the file address that weekend.  Surveillance efforts were then
terminated at that time.
" recommendations="Further surveillance should be suspended until the
claimant?s next doctor appointment, when the location of the claimant?s new
residence could be obtained.
" active="1" submit_for_review="2003-05-19T11:53:39.717" enclosures="Report,
Invoice" investigator_initials="KS" finding_enclosures="REPORT, INVOICE"
assignor_nm="JON SMITH" assignor_address1="500 XXXXX XXXX PARKWAY"
assignor_city="XXXXXXX" assignor_state="GA" assignor_zip="33333"
client_name="SSSS"><patient external_ref_num="867530933" ssn="999999999"
birthdate="1975-09-07T00:00:00" injury_dt="2002-03-18T00:00:00"
patient_injury_type="BACK, NECK PAIN" patient_nm="FIRST LAST"
patient_address1="2056 XXXXX " patient_city="XXXXXXX" patient_state="GA"
patient_zip="333333"><case
file_number="02-0033"/></patient></finding></root>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread