XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 22nd, 2004, 09:59 AM
Kneedownzx9r Kneedownzx9r is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 Kneedownzx9r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Newbie to XML/XSLT/Whitespace problems



Hi, I am trying out some xml/xslt stuff for a new procedure manual type database. Basically, I have an access database with some memo fields where users type in instructions.

These can have multiple parts so they use spaces or tabs to indent certain pieces of text. When generate my xml to display it, all of the indentation is there in the xml. When I transform it via XLST style sheet all of the formatting is gone.

For example :-

This proc has two parts :-

1. Start
2. End

Comes out as :-

This proc has two parts 1. Start 2. End

I've tried "preserve-space" to no avail - is there a way of keeping this nice formatting the users have painstakingly input ??????????

Meant to say also that I generate all XML via MSXML and VBA from within the access d/b.

XSL Style sheet typed up by hand.

Cheers

Reply With Quote
  #2  
Old June 22nd, 2004, 11:08 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,569 jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 22 h 42 m 51 sec
Reputation Power: 835
Try enclosing your text in <![CDATA[ ]]> tags:
Code:
<xml_tag><![CDATA[multi-line
text
goes
here]]></xml_tag>
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Reply With Quote
  #3  
Old June 22nd, 2004, 11:53 AM
Kneedownzx9r Kneedownzx9r is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 Kneedownzx9r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Many thanks for the post and I can understand the theory behind it.

So, OK, coded that into the source xml document manually without worrying about how to do it via VBA for the moment and I can see that it groups the multi-line text together if I open it without the XSLT stylesheet.

However, when I put the xslt stylesheet in, the formatting disappears. I am using Jeni Tennison's book (amongst others) and have an <xslutput> element in my XSLT stylesheet as well in an attempt to solve the problem - but all to no avail. I've tried with this element in and with it out as well.

Do you have any other suggestions I could try out ?

This is rapidly sapping my confidence in XML/XSLT as something I want to introduce into our organisation !!!!!!!!!!!

Reply With Quote
  #4  
Old June 22nd, 2004, 11:58 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,569 jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 22 h 42 m 51 sec
Reputation Power: 835
Sorry, CDATA was not the correct suggestion.

Whitespace is one of those XML / XSLT quirks. I searched Google for "xml whitespace" and came up with several examples and articles on how to deal with whitespace.

Reply With Quote
  #5  
Old June 23rd, 2004, 09:37 AM
Kneedownzx9r Kneedownzx9r is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 Kneedownzx9r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Tried out various things

I did of course search on the internet prior to coming to an expert forum.

I have tried the XSL:PRESERVE and XSL:OUTPUT approaches to no avail.

Does anyone have a clue how to keep the formatting I have in my XML after the XSL transformation.

I am thinking of re-writing this part of my application to produce Word documents via the MSWORD object model and junking the XML/XSL experiment.

Reply With Quote
  #6  
Old June 23rd, 2004, 09:38 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,569 jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 22 h 42 m 51 sec
Reputation Power: 835
Post (or attach) the XML and XSL files you have and I'll take a look.

Reply With Quote
  #7  
Old June 23rd, 2004, 10:03 AM
Kneedownzx9r Kneedownzx9r is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 Kneedownzx9r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
XML/XSL In question - sensitive info removed !

Thank you for offering to have a look at my hamfisted XML/XSL!

XML FILE - This is a cut down version of the actual file. the <ProcOverVw> element is where the formatting is lost.
Code:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="XMLTest5.xsl"?>
<Procedures>
  <ProcHead xml:space="preserve">
    <ProcNbr>4</ProcNbr>
    <ProcDept>SD</ProcDept>
    <ProcTitle>Mailing History Upload</ProcTitle>
    <ProcOuts> Mailing history records are appended to the mailinghistory_p table in the  database.
Customer records have the SUPPRESSED field updated to ‘C’ where the cust_no exists in the control file.</ProcOuts>
    <ProcAuth>A Developer</ProcAuth>
    <ProcVrsn>1</ProcVrsn>
    <ProcDate>10/06/04</ProcDate>
    <ProcAmnd> </ProcAmnd>
    <ProcOvrVw xml:space="preserve"><![CDATA[There are two parts to this process depending on the files received for upload.

     1. Load mailing history data.
     2. Update control records.

If a control file is received then the procedures to update these should be followed (steps 13 to 26) else these steps can be ignored.  

File(s) are supplied by the Research Dept.  The mailing history file is loaded into the mailinghist table in the database.  The control file (if it is supplied) is loaded into the TEMP_CUST table using sqlload in UNIX then an update query is performed in SQL Plus.  

Mailing History file :

The file being uploaded should be renamed to mailhist.txt and the format should match the control script (mailhist_p2.ctl) used for upload.

A log file is created during the upload (mailhist_p2.log).  Any rejected records are written to a bad file (mailhist_p.bad).  

Control file :

The file being uploaded should be renamed to control.txt and the format should match the control script (control.ctl) used for upload.

A log file is created during the upload (control.log).  Any rejected records are written to a bad file (control.bad).  

The log files contain the upload statistics, formatting applied to any columns and the reason that any records were rejected.  The .bad files contain any records that have been rejected.  If any bad files exists after uploads then check the contents.  If it contains any records other than the header record then check the log file to determine why these records were rejected.  These rejected records will need to be amended and re-uploaded.  All records written to the database are committed.  A maximum of fifty (50) records will be rejected befor the upload is aborted.]]></ProcOvrVw>
   </ProcHead>
   <ProcInstrs>
      <ProcInstr>   
      </ProcInstr>
   </ProcInstrs>
</Procedures>
Stylesheet :-
Code:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" 
            indent="yes"
	    media-type="text/html"
            cdata-section-elements="ProcOverVw"/>

<xsl:preserve-space elements="ProcOverVw" />

<!-- tell xslt which node to start with this is the top level template definition 
     the backslash says the context node is the root node i.e. the whole document -->
	
   <xsl:template match="/">

      <html>
	 
         <head>

	    <TITLE>Procedure Document(s)</TITLE>

         </head>
	
	 <body style="font-family: Arial">

<!-- tell xslt you have templates you wish to use to process the CHILDREN of the start node -->	
 
	    <xsl:apply-templates /> 

	    <br/>

         </body>
      </html> 
   
   </xsl:template>

   <xsl:template match="ProcHead">
        
        <xsl:variable name="overtxt" select = "ProcOverVw" />

        <xsl:message>
             $overtxt
        </xsl:message>
	
        <p><left><b><h2><xsl:value-of select="ProcTitle"/></h2></b></left></p>
        
        <table align = "center" bgcolor="#9acd33" width="600">
	
	   <tr>
	      <td><b><xsl:text>Proc ID : </xsl:text></b></td>
              <td><xsl:value-of select="ProcNbr"/></td>
           </tr>

	   <tr>
	      <td><b><xsl:text>Department: </xsl:text></b></td>
              <td><xsl:value-of select="ProcDept"/></td>
           </tr>

	   <tr>
	      <td><b><xsl:text>Proc Author : </xsl:text></b></td>
              <td><xsl:value-of select="ProcAuth"/></td>
           </tr>

	   <tr>
	      <td><b><xsl:text>Date Written: </xsl:text></b></td>
              <td><xsl:value-of select="ProcDate"/></td>
           </tr>

	   <tr>
	      <td><b><xsl:text>Date Last Amended : </xsl:text></b></td>
              <td><xsl:value-of select="ProcAmnd"/></td>
           </tr>

	   <tr>
	      <td><b><xsl:text>Version Nbr: </xsl:text></b></td>
              <td><xsl:value-of select="ProcVrsn"/></td>
           </tr>



        </table>

	<p><b><xsl:text>Overview: </xsl:text></b></p>
	<p>><xsl:value-of select="ProcOvrVw"/></p>
	<p><b><xsl:text>Instructions: </xsl:text></b></p>

   </xsl:template>

   <xsl:template match="ProcInstrs">

	<xsl:apply-templates />
       
   </xsl:template> 

   <xsl:template match="ProcInstr">

             <p><xsl:value-of select="." /></p>
       
   </xsl:template>

   <xsl:template match="ProcBmp">

	<img>
		<xsl:attribute name="src">
  			<xsl:value-of select="@src" /><xsl:text> </xsl:text>
	 	</xsl:attribute> 

		<xsl:attribute name="alt">
  			<xsl:value-of select="@alt" />
	 	</xsl:attribute>   

		<xsl:attribute name="alt">
  			<xsl:value-of select="@width" />
	 	</xsl:attribute>  

		<xsl:attribute name="alt">
  			<xsl:value-of select="@height" />
	 	</xsl:attribute>        
	</img>

   </xsl:template>
 
</xsl:stylesheet>

Last edited by jharnois : June 28th, 2004 at 05:42 PM.

Reply With Quote
  #8  
Old June 28th, 2004, 06:09 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,569 jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level)jharnois User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 22 h 42 m 51 sec
Reputation Power: 835
Code:
<!-- <p>><xsl:value-of select="ProcOvrVw"/></p>-->
<pre><xsl:value-of select="ProcOvrVw" /></pre>
This may not be the solution you were after, but it does work. You can then use CSS to give that <pre> tag the same properties as <p> tags, so it will look just like a bunch of <p>s put together. I couldn't come up with another solution, but I swear there should be an XML solution. Playing with the <output> attribute values might help.

Reply With Quote
  #9  
Old June 29th, 2004, 05:11 AM
Kneedownzx9r Kneedownzx9r is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 Kneedownzx9r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Test solution

Thank you for the effort - I will try this today at some point and post how I got on !

Thanks again.

Reply With Quote
  #10  
Old July 7th, 2004, 07:44 AM
Kneedownzx9r Kneedownzx9r is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 Kneedownzx9r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Eureka

The <pre> tag and CSS solution works a treat.

Many thanks...............

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Newbie to XML/XSLT/Whitespace problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
   <