Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting Access Query to XML with Line Breaks 1

Status
Not open for further replies.

fallenrayne

Technical User
Dec 14, 2005
7
US
Hi everyone,

First off, nice forum you have here, lots of great information. I have a small problem that is ending up being more of a headache than I like. I currently export an Access query that has 3 memo fields into XML. When they turn into XML the linebreaks that I once had are lost. I am trying to find a way to make the XML see the linebreaks whether I have to put in code to force XML to identify the linebreaks or whatever. The big issue is when I then use XSLT to turn it into xHTML and all of my memo fields have text that just runs together. Even if I had to put <br/> tags into the Access database and then export that out to XML and parse it properly through XSLT. I just don't know how to go about doing that. Any help with this would be great. Thanks in advance :)

- Brandon
 
Brandon,

I just looked at the Help in my copy of Access, but I don't see where to grab on to the export process to affect this.

One think you might try is to code the <br/> using entities which might make it through the export steps.
Code:
&lt;br/&gt;
Perhaps...

Tom Morrison
 
Problem is that the XSLT then parses out the & into amp;. Honestly if I could find someway to stop the XSLT from parsing out <br/> then I would be able to use that. The problem isn't with the XML getting the wrong information really because I can add <br/> into the field I export and it shows 2 lines in the XML and shows the <br/> tag just fine. I'm not sure what type of XSLT function to use to force it to print that tag properly or even how to implement it into the XSLT. I'm still really new at XML and XSLT structure.

Thank you for responding to the post btw :)
 
Ok, let me re-ask this in a different way.

Is it possible in XSL to make a function that basically says:

If this statement has "<br/>" in it
Print </br> instead
Else
Ignore

Or is there a way to replace all of the "<br/>" with <br/> so that in the transformation I can actually get break tags in there?

Thank you for the help so far.

- Brandon
 
[1] I think the easiest solution is to wrap the memo field's content with <pre>...</pre> tag when you further render the xml via an xsl file. That would render the newline in the memo field.

[2] Another way to go is as said replace newline non-printable character by <br /> and use xsl:preserve-space on elements="memo" where <memo>...</memo> contains the exported contents of the memo fields.

 
How do I make it so that the < and > don't get turned into &lt; and &gt; ? That is my other big problem. Even if I wrap it in <pre> tags the < > still get changed. I need someway to preserve the html tag there. It looks fine in the XML its just the XSL that is changing the tags on transformation.

Thank you for your help.

- Brandon
 
Why keep thing always abstract? Show typicals of what you have on the memo in the xml. Do it have html tag inside?!
 
I don't have the code on this system and I kinda have to keep it abstract and generalized. Emm..

Basically what the XML looks like is this

<MemoTag>
<![CDATA[
<pre>
• First bullet
• Second bullet
</pre>
]]>
</MemoTag>

I then pass that through an XSLT to transform it into HTML. When it passes through the XSLT the <pre> tag turns into &lt;pre&gt;. I am wondering if there is a way to preserve the html tags inside of the CDATA.
 
The pre-tag is for xsl rendering in html output. Are you saying it appears in the export xml? You don't have the export to xml, not even a realistic sample? How can you work on it? Maybe some other who has better crystal ball.
 
I was able to find it on my own by searching on "How To Embed CData" in Google. The proper way to do it in your XSL is to use disable-output-escaping="yes". e.g.

<xsl:value-of select="MemoField" disable-output-escaping="yes" />

and that will preserve the html tags in the CData of the XML.

Thanks

-Brandon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top