473,554 Members | 3,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[XSL] How do i get & #160; to pass through?

I have a basic understanding of this, so forgive me if I am overly
simplistic in my explanation of my problem..

I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e.  ) and it seems to be converting the
character to its UNICODE representation.

Take this source XML document:

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
some space sepa rated text
</sourcexml>

And this stylesheet:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|*|tex t()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|*|te xt()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

I am trying to get it to regurgitate the original document, with the
 's intact. Instead I am getting bizarre characters (copied from
windows CMD window):

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
someáspaceásepa ratedátext
</sourcexml>

Here is how I am doing my transform (java code):

SAXSource in = new SAXSource(new InputSource(new
StringReader(th is.xmlDocument) ));

// build the out result
StringWriter writer = new StringWriter();
StreamResult out = new StreamResult(wr iter);

// build the transformer
SAXSource stylesheetIn = new SAXSource(new InputSource(new
StringReader(th is.xslStyleshee t)));
Transformer transformer =
TransformerFact ory.newInstance ().newTransform er(stylesheetIn );

// transform the string.
transformer.tra nsform(in,out);

// return the transformation result.
return writer.toString ();

Any ideas? Any help would be very appreciated. Thanks :)

Jul 20 '05 #1
9 8535
Collin VanDyck <se************ *****@hannonhil l.com> scribbled the following
on comp.lang.java. programmer:
I have a basic understanding of this, so forgive me if I am overly
simplistic in my explanation of my problem.. I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e.  ) and it seems to be converting the
character to its UNICODE representation. Take this source XML document: <?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
some space sepa rated text
</sourcexml>


I'm not sure if this is what you want, but one way to get the literal
string " " to appear in the output is to write it as:
"&amp;#160; " in the source code. To get *that* to appear, write it as
"&amp;amp;#160; " and so on. Of course I could be trying to solve the
wrong problem here.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"This isn't right. This isn't even wrong."
- Wolfgang Pauli
Jul 20 '05 #2
Hi...

Thanks for the reply, but I tried that, and it produced:

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
some&amp;amp;#1 60;space&amp;am p;#160;separate d&amp;amp;#160; text
</sourcexml>

where what I am aiming to get is:

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
some space sepa rated text
</sourcexml>

thanks,

"Joona I Palaste" <pa*****@cc.hel sinki.fi> wrote in message
news:bp******** *@oravannahka.h elsinki.fi...
Collin VanDyck <se************ *****@hannonhil l.com> scribbled the following on comp.lang.java. programmer:
I have a basic understanding of this, so forgive me if I am overly
simplistic in my explanation of my problem..

I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e.  ) and it seems to be converting the
character to its UNICODE representation.

Take this source XML document:

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
some space sepa rated text
</sourcexml>


I'm not sure if this is what you want, but one way to get the literal
string " " to appear in the output is to write it as:
"&amp;#160; " in the source code. To get *that* to appear, write it as
"&amp;amp;#160; " and so on. Of course I could be trying to solve the
wrong problem here.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"This isn't right. This isn't even wrong."
- Wolfgang Pauli


Jul 20 '05 #3
I thought these character entity-references need 4 digits if you want to
specify a decimal value
(character-code 160 as the &nbsp; in HTML) (and not 3, as in your example).

Try

 

(instead of  )

-- Anton.

"Collin VanDyck" <se************ *****@hannonhil l.com> wrote in message
news:8a******** *************** *******@news.te ranews.com...
I have a basic understanding of this, so forgive me if I am overly
simplistic in my explanation of my problem..

I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e.  ) and it seems to be converting the
character to its UNICODE representation.

Take this source XML document:

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
some space sepa rated text
</sourcexml>

And this stylesheet:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|*|tex t()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|*|te xt()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

I am trying to get it to regurgitate the original document, with the
 's intact. Instead I am getting bizarre characters (copied from
windows CMD window):

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
someáspaceásepa ratedátext
</sourcexml>

Here is how I am doing my transform (java code):

SAXSource in = new SAXSource(new InputSource(new
StringReader(th is.xmlDocument) ));

// build the out result
StringWriter writer = new StringWriter();
StreamResult out = new StreamResult(wr iter);

// build the transformer
SAXSource stylesheetIn = new SAXSource(new InputSource(new
StringReader(th is.xslStyleshee t)));
Transformer transformer =
TransformerFact ory.newInstance ().newTransform er(stylesheetIn );

// transform the string.
transformer.tra nsform(in,out);

// return the transformation result.
return writer.toString ();

Any ideas? Any help would be very appreciated. Thanks :)

Jul 20 '05 #4
Thanks, but same result. I ended up deciding to pass everything through an
xml encoder-decoder that would do a regex replaceAll on

&#([0-9+);

to

[unicode]$1[/unicode]

And after the transform was done, reverse it back into the character
reference syntax.
"Anton Spaans" <aspaans at(noSPAM) smarttime dot(noSPAM) com> wrote in
message news:86******** ************@sp eakeasy.net...
I thought these character entity-references need 4 digits if you want to
specify a decimal value
(character-code 160 as the &nbsp; in HTML) (and not 3, as in your example).
Try

 

(instead of  )

-- Anton.

"Collin VanDyck" <se************ *****@hannonhil l.com> wrote in message
news:8a******** *************** *******@news.te ranews.com...
I have a basic understanding of this, so forgive me if I am overly
simplistic in my explanation of my problem..

I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e.  ) and it seems to be converting the
character to its UNICODE representation.

Take this source XML document:

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
some space sepa rated text
</sourcexml>

And this stylesheet:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|*|tex t()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|*|te xt()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

I am trying to get it to regurgitate the original document, with the
 's intact. Instead I am getting bizarre characters (copied from
windows CMD window):

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
someáspaceásepa ratedátext
</sourcexml>

Here is how I am doing my transform (java code):

SAXSource in = new SAXSource(new InputSource(new
StringReader(th is.xmlDocument) ));

// build the out result
StringWriter writer = new StringWriter();
StreamResult out = new StreamResult(wr iter);

// build the transformer
SAXSource stylesheetIn = new SAXSource(new InputSource(new
StringReader(th is.xslStyleshee t)));
Transformer transformer =
TransformerFact ory.newInstance ().newTransform er(stylesheetIn );

// transform the string.
transformer.tra nsform(in,out);

// return the transformation result.
return writer.toString ();

Any ideas? Any help would be very appreciated. Thanks :)



Jul 20 '05 #5
"Collin VanDyck" <se************ *****@hannonhil l.com> wrote in message
news:8a******** *************** *******@news.te ranews.com...
I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e.  ) and it seems to be converting the
character to its UNICODE representation.


Probably UTF-8 encoded. Try specifying the encoding to generate in
your xsl:output element. Iso-8859-1 should do what you want.

Groetjes,
Maarten Wiltink
Jul 20 '05 #6
Collin VanDyck wrote:
I have a basic understanding of this, so forgive me if I am overly
simplistic in my explanation of my problem..

I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e.  ) and it seems to be converting the
character to its UNICODE representation.

Take this source XML document:

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
some space sepa rated text
</sourcexml>

And this stylesheet:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|*|tex t()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|*|te xt()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

I am trying to get it to regurgitate the original document, with the
 's intact. Instead I am getting bizarre characters (copied from
windows CMD window):


That's how the XPath data model works - the information about whether a
character originally was entered as a numerical entitity isn't available
- so there's no chance to preserve that bit of information using XSLT.

(amazing how many wrong suggestions were made :-)

Julian
Jul 20 '05 #7
Collin VanDyck wrote:
I have a basic understanding of this, so forgive me if I am overly
simplistic in my explanation of my problem..

I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e.  ) and it seems to be converting the
character to its UNICODE representation.

Take this source XML document:

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
some space sepa rated text
</sourcexml>

And this stylesheet:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|*|tex t()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|*|te xt()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

I am trying to get it to regurgitate the original document, with the
 's intact. Instead I am getting bizarre characters (copied from
windows CMD window):

<?xml version="1.0" encoding="UTF-8"?>
<sourcexml>
someáspaceásepa ratedátext
</sourcexml>


This an understandable behaviour:

* The   is parsed by the XML parser, and is considered being a
NO-BREAK SPACE Unicode character. See here:
<http://www.unicode.org/charts/PDF/U0080.pdf>, character 0xA0.

* The XML is parsed with the XSL, and the NO-BREAK SPACE Unicode
character is kept unchanged in the result XML document.

* The output document is encoded as ISO-8859-1 (Latin 1) for some reason
(this is the default character encoding on many platforms), instead of
UTF-8, and in ISO-8859-1, the NO-BREAK SPACE character is encoded as a
single 0xA0 byte.

* When the CMD window tries to display the character, it understands the
XML document as being encoded in the CP437 character set (the *very* old
DOS character set, for compatibility). It gets the 0xA0 byte, and in
CP437 the 0xA0 byte represents the LATIN SMALL LETTER A WITH ACUTE
Unicode character, which is what you see. See here:
<http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT>
Of course in UTF-8 the output would have been the folowing bytes:
some space separated text (Latin 1 bytes)
which in CMD would be displayed as something I can't type here, because
it invloves 0xc2 'BOX DRAWINGS LIGHT DOWN AND HORIZONTAL' characters.
It would probably have looked like this:
some|áspace|áse parated|átext

--
Laurent

Jul 20 '05 #8
"Maarten Wiltink" <ma*****@kitten sandcats.net> wrote in message
news:3f******** *************** @news.xs4all.nl ...
"Collin VanDyck" <se************ *****@hannonhil l.com> wrote in message
news:8a******** *************** *******@news.te ranews.com...
I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e.  ) and it seems to be converting the
character to its UNICODE representation.


Probably UTF-8 encoded. Try specifying the encoding to generate in
your xsl:output element. Iso-8859-1 should do what you want.


On second thoughts, it shouldn't. Since U+00a0 is a valid character
in iso-8859-1, it will be output verbatim. Asking for output in
(7-bits) us-ascii should cause the processor to produce a character
entity.

Groetjes,
Maarten Wiltink
Jul 20 '05 #9
In article <8a************ *************** ***@news.terane ws.com>,
Collin VanDyck <se************ *****@hannonhil l.com> wrote:
I am trying to get a Java/Xalan transform to pass through a numeric
character reference (i.e.  ) and it seems to be converting the
character to its UNICODE representation.


This is normal. *Why* do you want to have it output as  ? It
shouldn't make any difference to the programs that use the output, if
they read it as XML.

If you want it for readability, you could specify that the output
encoding should be ascii.

-- Richard

--
Spam filter: to mail me from a .com/.net site, put my surname in the headers.

FreeBSD rules!
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2064
by: wharfprada | last post by:
this one is very puzzling to me. everytime i add   to my xsl file it is displayed as ? mark. I changed my encoding from UTF-8 to ISO-8859-1 and was still gettin the same problem. any idea Thank
2
15206
by: Robert | last post by:
when using the following function to create a pass through query is there a way to set the query property, "Returns Rows" to no. The default is yes. Since we are planning to create the pass through with new parameters in the where clause we need to set it each time. Thanx in advnance. Function CreateSPT(SPTQueryName As String, strSQL As...
7
21592
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the server ? Is it possible to use parameters in pass-through queries ? An additional question: Is it possible to connect to a database on MySQL or...
3
2736
by: Zlatko Matić | last post by:
Hello. I'm wondernig what is happennig whith saved pass-through queries nested in regular JET query if regular JET query just filtrates result by start/end date...Does pass-through query first returns all rows from server and then JET filtrates result by start/end date, or JET first communicates with server so that server returns only those...
0
3308
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems appear when someone is trying to use it as front-end for real server database systems such as PostgreSQL or MySQL. One of these problems is regarding...
3
12583
by: ILCSP | last post by:
Hello, I'm fairly new to the concept of running action pass through queries (insert, update, etc.) from Access 2000. I have a SQL Server 2000 database and I'm using a Access 2K database as my front end. I'm using a blank pass through query which gets the Transact-SQL part inserted from a button in my form. After inserting the Transact-SQL...
1
4279
by: Greg Strong | last post by:
Hello All, Why would brackets be added to the SQL of a pass through query to Oracle? If I paste the debug print of the SQL statement into SQLPlus of Oracle's XE edition it works, and does NOT have brackets around the tablespace preceding the table name. However when I create the pass through query in VB brackets are placed around the...
5
6311
by: marshmallowww | last post by:
I have an Access 2000 mde application which uses ADO and pass through queries to communicate with SQL Server 7, 2000 or 2005. Some of my customers, especially those with SQL Server 2005, have had pass-through queries fail due to intermittent connection failures. I can easily restablish a connection for ADO. My problem is with...
13
3707
by: magickarle | last post by:
Hi, I got a pass-through query (that takes about 15 mins to process) I would like to integrate variables to it. IE: something simple: Select EmplID from empl_Lst where empl_lst.timestamp between !! And !! Not sure how to do so (should it be a query in Access or a macro) The connection would be ODBC.
0
7539
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7819
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8055
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3589
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2030
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1149
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
858
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.