f



How can I get attribute values to not get converted from ' to ' or & to & or < to > ?

Hi, my mind is going crazy.  I have tried everything I can think of to
no
avail.
 I have tried Disable Output Escaping.
I tried to think of a way of enclosing the attribute data in a CDATA
element.  That did not parse.

Here is my question:

How can I get attribute values to not get converted from ' to '
or & to & or < to > ?


It seems like if I take the xsl:value-of an attribute and then output
that
value into another xml it get's converted.

The problem is I am importing this stuff into a DB and I need to keep
all
those ' and other escapings..

Also, is there a way to do something like this
<![CDATA[
<xsl:value-of select="@CATEGORY" />
]]>

The problem with this is it gives me
    <xsl:value-of select="@CATEGORY" />

    where I want
Men&apos;s Clothing

Thanks any help would be appreciated...


Here is my source xml, XSL, and outfile:

Source XML:

<import>
<CAT>
        <row CATEGORY="Men&apos;s Clothing" />
</CAT>
</import>

XSL:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

	<xsl:output indent="yes" method="xml" />
    <xsl:strip-space elements="*"/>

	<xsl:template name="frank_data">

 		<xsl:param name="id" />


		<xsl:element name="frankgroup">
    		<xsl:attribute name="identifier"><xsl:value-of select="$id"
/></xsl:attribute>
   		</xsl:element>

    </xsl:template>

    <xsl:template match="/">

        <xsl:element name="import">
            <xsl:apply-templates />
        </xsl:element>

    </xsl:template>

    <xsl:template match="CAT">
		<xsl:for-each select="*">
		<xsl:call-template name="frank_data">
				<xsl:with-param name="id" select="@CATEGORY" />
  		</xsl:call-template>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>
Output:

<import>
<frankgroup 
        id="Men's Clothing" />
</import>

0
5/6/2005 3:40:05 PM
comp.text.xml 8781 articles. 0 followers. Post Follow

12 Replies
1096 Views

Similar Articles

[PageSpeed] 30


>  How can I get attribute values to not get converted from &apos; to '
>  or &amp; to & or &lt; to > ?

The whole point about &lt; is that it means the same thing as > (not
always in element content if the preceding two characters were ]] but in
attribute values they always mean the same thing.
If you go
<foo bar="&gt;"/><foo bar=">"/> Then XSLT will see identical input from
the two forms, and it may use either form on output. It has no way of
knowing which form was used, any more than it has of knowing whther yiou
used " or ' to surround the attribute value.

> The problem is I am importing this stuff into a DB and I need to keep
> all those &apos; and other escapings..

If that import mechanism is not aware of XML conventions so is broken by
XML quoting syntax they you will have to use the text output method of
xslt and write out the literal tags that you want rather than allowing
XSLT to linearise an element tree for you. But you lose most of the
benefits of xslt doing that.

so 
<xsl:output method="text"/>
....

<xsl:template match="xyz">
  &lt;foo bar="<xsl:value-of select="@CATEGORY"/>" ..../&gt;
....



  Also, is there a way to do something like this
  <![CDATA[
  <xsl:value-of select="@CATEGORY" />
  ]]>


Well you can do exactly that, as you observe, but then the
<xsl:value-o
is taken as character data not element markup.


The problem with this is it gives me
    <xsl:value-of select="@CATEGORY" />


    where I want
  Men&apos;s Clothing

As I say above If you mean that you had an input string of
Men&apos;s Clothing
and you need it to come out as
Men&apos;s Clothing
and not as
Men's Clothing
then basically you can't use XSLT as the XML parser  will report these
two things as the same. So there is no way XSLT can preserve the difference.


David

0
davidc5020 (601)
5/6/2005 4:04:25 PM
Hmm, whell what if you want everythign to come out as


&apos; then?


I mean actually I don't care if it comes in as ' or &apos;

I just want it to come out as &apos;

0
5/6/2005 5:37:22 PM
In article <1115401042.382945.27160@z14g2000cwz.googlegroups.com>,
Sammy <fred.shady@gmail.com> wrote:

>Hmm, whell what if you want everythign to come out as
>&apos; then?

The answer from an XML point of view is that you shouldn't want that!

If you need to enforce it for compatibility with some non-XML system
(such as your database), then you need a special purpose tool to
convert it from "generic XML" to "the subset of XML my application
needs".

-- Richard
0
richard91 (3692)
5/6/2005 5:41:03 PM
Are there any templates out there for converting all your data from

', <, >, &

to 

&apos;  &lt; &gt; &amp;

?

0
5/6/2005 5:44:45 PM

Sammy wrote:

> Hmm, whell what if you want everythign to come out as
> 
> 
> &apos; then?

XSLT gives you a result tree, you would then need to write your own 
serializer that follows the conventions you define.

-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
0
mahotrash (2052)
5/6/2005 5:45:18 PM
Oh, and I really like your FAQ by the way David...


I've been reading it a lot over the last 2 weeks....

0
5/6/2005 6:01:59 PM
Yeah, but how do HTML peeps do this then?

I mean they use XSL to create HTML all the time and it comes out as
&apos; ??

Am I missing something here?

Those peeps who create HTML have to have it come out in &apos, and
&nsps; and &amp;

Or there HTML won't work...

What do those peeps do?

0
5/6/2005 6:05:29 PM
It would seem like one stategy is to just have it output
HTML?

Does this work?

If I change the <xsl:output element to say HTML

will it output &apos;???

0
5/6/2005 6:15:42 PM
Thanks for all the quick responces by the way.

I appreciate your help....

0
5/6/2005 6:17:04 PM
"Sammy" <fred.shady@gmail.com> writes:

> Yeah, but how do HTML peeps do this then?
> 
> I mean they use XSL to create HTML all the time and it comes out as
> &apos; ??
> 
> Am I missing something here?

yes.
 
> Those peeps who create HTML have to have it come out in &apos, and
> &nsps; and &amp;
> 
> Or there HTML won't work...

It will work. look at 
<p>your&apos;s and your's</p>
 in an html  browser of your choice. &apos; means the same thing as '
The _only_ time you need to use &apos; is to get a ' in an ' delimited
attribute value
foo='your&apos;s'
XSLT will do that automatically when it's needed.

> 
> What do those peeps do?

They let XSLT take care of the details.

David
0
davidc5020 (601)
5/6/2005 9:08:15 PM
"Sammy" <fred.shady@gmail.com> writes:

> Oh, and I really like your FAQ by the way David...
> 
> 
> I've been reading it a lot over the last 2 weeks....

different david
0
davidc5020 (601)
5/6/2005 9:08:57 PM
In article <1115403342.254397.47080@g14g2000cwa.googlegroups.com>,
Sammy <fred.shady@gmail.com> wrote:

>It would seem like one stategy is to just have it output
>HTML?
>
>Does this work?
>
>If I change the <xsl:output element to say HTML
>
>will it output &apos;???

No, because ' is perfectly good in HTML as well as in XML.

-- Richard



0
richard91 (3692)
5/6/2005 10:14:02 PM
Reply:

Similar Artilces:

'&&&&a'="&&&&a."
I need a data step that is equivalent to data _NULL_; file print; put '&&&&&&a=' "&&&&&&a"; run; Yet the number of & is a variable, I need to write a Macro, so far I got only half of the code('&&&&&&a.='), I don't know how to put the other half ("&&&&&&a.") into Macro Thanks. %Macro R(k); data _NULL_; file print; put %do i= 1 %to &k.; '&' %end; 'a=' ; run; %mend; %R(10); ==================================================...

Re: &&&&&&
Talbot, Its basic macro aper math. With each pass of the macro processor it reduces && to &. in yoru case: %put &&mlv&mlin. = &&&&&&mlv&mlin. ; 1st pass: &mlv5 = &&&mlv5 2nd Pass: Daisy = &Daisy 3rd Pass : Daisy = Yellow Toby Dunn From: Talbot Michael Katz <topkatz@MSN.COM> Reply-To: Talbot Michael Katz <topkatz@MSN.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: &&&&&& Date: Thu, 9 Jun 2005 13:38:44 -0400 Received: from malibu.cc.uga.edu ([128.192.1.103]) by MC8-F21.hotmail...

&& and &
What exactly is the difference between && and & (|| and |)? When does it generates different results? Is the & wrong now from R14 on? Best regards Prom Prom wrote: > What exactly is the difference between && and & (|| and |)? When does > it generates different results? Is the & wrong now from R14 on? > > Best regards > Prom 'help &' shows: Logical operators. Short-circuit logical AND && Short-circuit logical OR || and - Element-wise logical AND &...

& and &amp;
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved and redisplayed it is displayed as simply &. HTML snippet: <TEXTAREA NAME="p_html" ROWS=6 COLS=70 ALIGN="VIRTUAL" WRAP="YES"> fred & &amp; </TEXTAREA> When displayed, the user predictably sees fred & & What workarounds are there for this - I am sure it's a problem for others - is there a way...

Re: &&&&&& #11
Michael, Where were you when I needed you? Just how long have you kept that naughty question bottled up where it cannot see the light of day? How many others harbor that naughty question? Well, all of you got some answers today. Some technically perfect regurgitations of the SAS documentation without a care about consequences which those who don't like to read for themselves will find somewhat useful. Some sagely suggesting that some newer SAS Constructs might be worth investigating, and, indeed, there may be something worth examining about your approach to solving problems when you t...

Re: &&&&&& #12
Talbot, From another message you already seem satisfied with the information given about your problem, but I will add my penny thoughts for they give a different point of view. The basic question might be interpreted as, "Why does it take so many ampersands to express 'daisy=yellow'?" The implied question might be what is wrong with my structure and how should it be fixed? I am interested in both. A macro variable can be thought of as a name pointing at a value. So a name can point at a name that can point at a value, etc. Let's look at the problem by analogy. Suppo...

Re: &&&&&& #5
Toby, Fair to disagree but the approach I suggested works extremely well, is easy to debug, and has proven itself time after time. As the famous macro or not debate showed a few months back, there are lots of ways to handle code gen...macro is merely 1 way. The limit here is one of comfort: where does an individual programmer feel comfortable technology and approach-wise. If macro is it, then that is what you will tend to drift toward. If it is SCL, as Joe states, then it will be SCL. Personally, I use macros (to a point), %includes, c#, CodeSmith, and a host of other methods to gen code dep...

Re: &&&&&& #4
> From: Talbot Michael Katz > It requires SIX ampersands to resolve the macro variable > example below: > > data _null_ ; > set DS1 end = last ; > call symput("mlv" || compress(put(_N_,best32.)), mli) > ; > call symput(mli, tdt) ; > if last then do ; > call symput("mlin", compress(put(_N_,best32.))) ; > end ; > run ; > %put &&mlv&mlin. = &&&&&&mlv&mlin. ; > > (So, if there are five observations in the data set, and the > fifth value of > mli is "DAISY" and the fi...

Re: &&&&&& #13
Bold=Ian Whitlock Faint Italics=Joe Whitehurst A macro variable can be thought of as a name pointing at a value. A named scl list item can be thought of as a name pointing at a value. So a name can point at a name that can point at a value, etc. So a named scl list item can be thought of as a named scl list item that can point at a named scl list item that can point at a named scl list item that can point at a value which can continue to whatever level of abstraction you wish without ever using any concatenated ampersands. Let's look at the problem by analogy. Suppose you go to a pa...

Re: &&&&&& #10
Thank you, Toby et al for your answers, opinions, advice, criticism, etc. I almost think I'm beginning to get it. Let me regurgitate this to be sure: Given &&&&&&mlv&mlin., I resolve &mlin. = 5 and reduce the &&&&&& to &&& to get &&&mlv5. Then I resolve &mlv5. = DAISY and reduce the && to & to get &DAISY. Finally I resolve &DAISY. = YELLOW. So, it looks to me like once I reach a stage where I have a string of ampersands followed by a "pure" name (i.e., one with no ampersa...

Re: &&&&&& #8
On Thu, 9 Jun 2005 13:38:44 -0400, Talbot Michael Katz <topkatz@MSN.COM> wrote: >Hi. > >It requires SIX ampersands to resolve the macro variable example below: > >data _null_ ; > set DS1 end = last ; > call symput("mlv" || compress(put(_N_,best32.)), mli) > ; > call symput(mli, tdt) ; > if last then do ; > call symput("mlin", compress(put(_N_,best32.))) ; > end ; >run ; >%put &&mlv&mlin. = &&&&&&mlv&mlin. ; > >(So, if there are five observations in the data set, and the fifth va...

Re: &&&&&& #9
"I have found that while in certain situations this may be the only way to accomplish something easily, it is over used and causes way more headaches than it is worth" My feeling on macros... Thanks, Alan Savian "Bridging SAS and Microsoft Technologies" -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of toby dunn Sent: Thursday, June 09, 2005 12:56 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: &&&&&& Alan, I seem to have started a hail storm here and I probably should have stated earlier that I don'...

Re: &&&&&& #3
toby dunn <tobydunn@hotmail.com> replied: > Alan, > > I disagree with that statement. I think the best solution would be to build > the dang thing the way he want with less macros. By sending your code out > then back in is in MO to much hassel for too little. > > the whole thingy could be done like this: > > data one ; > flower = 'Daisy' ; > color = 'Yellow' ; > run ; > > data two ; > set one ; > call symput ( compress('text'||_n_),compbl(flower||'='||color) ) ; > call symput ( 'index' , compre...

Re: &&&&&& #2
Alan, I disagree with that statement. I think the best solution would be to build the dang thing the way he want with less macros. By sending your code out then back in is in MO to much hassel for too little. the whole thingy could be done like this: data one ; flower = 'Daisy' ; color = 'Yellow' ; run ; data two ; set one ; call symput ( compress('text'||_n_),compbl(flower||'='||color) ) ; call symput ( 'index' , compress(_n_) ) ; run ; %put &&text&index ; Toby Dunn From: Alan Churchill <SASL001@SAVIAN.NET> Reply-To: A...

Re: &&&&&& #6
This is a prime example I use when I discuss what is wrong with the macro language. Yes, you can figure it out but an alternative would be to simply write your data step code out and then bring it back in so you know what is being submitted. data _null_ ; file 'c:\myfile.sas' ; put 'data ...;' ; ...more put statements... run; %include 'c:\myfile.sas' ; Others will argue for SCL or something else. Regardless, this application probably requires a complete rethink if you are using 6 ampersands. Thanks, Alan Savian "Bridging SAS and Microsoft Technologies...

Re: &&&&&& #7
Alan, I seem to have started a hail storm here and I probably should have stated earlier that I don't disagree with SCL or a rework of the code, but rather building and then sending the code out to a temp file and then %including it back in I like not. I have found that while in certain situations this may be the only way to accomplish something easily, it is over used and causes way more headaches than it is worth. As for the rest of your post I am right behind you. Toby Dunn From: Alan Churchill <SASL001@SAVIAN.NET> Reply-To: Alan Churchill <SASL001@SAVIAN.NET> To: ...

#######modernpractice.webs.com&&&&&&&
#######modernpractice.webs.com&&&&&&& play games win prizes nice friends cute only here nice music ...

#######modernpractice.webs.com&&&&&&&
#######modernpractice.webs.com&&&&&&& play games win prizes nice friends cute only here nice music ...

#######modernpractice.webs.com&&&&&&&
#######modernpractice.webs.com&&&&&&& play games win prizes nice friends cute only here nice music ...

A && B && ( C && D )
Hi all, I've four conditions expression, A, B, C, and D. Are the following two forms equivalent or not? A && B && ( C && D ) A && B && C && D Regards -- ..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :. Hongyi Zhao <hongyi.zhao@gmail.com> wrote: >Are the following two forms equivalent or not? > >A && B && ( C && D ) >A && B && C && D Yes. In either case, _all_ variables must be true for the expression to be true. The AND operato...

When I send email as HTML, why do erroneous whitespaces get introduced to the HTML source and a few < > chars get converted to &lt; and &gt; ???
I have the following script that reads in an HTML file containing a table t= hen sends it out via email with a content type of text/html. For some reason a few erroneous whitespaces get introduced to the HTML sour= ce and a few < > chars get converted to &lt; and &gt; ??? # Import libraries import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText buffer_results =3D open('results.html', 'r') HTMLContent =3D buffer_results.read() print repr(HTMLContent) buffer_results.close()=09 # Send out email notificat...

I want to save &lt;i&gt; but not &lt;img..&gt; how is that done?
[code] // FLAG ALL INCIDENTS OF LEGITIMATE TAGS BY CONVERTING <..> TO <!..!> for (int i = 0; i < parseVector.size(); i++) { this.content = this.content.replaceAll("<(/?)(" + (String)parseVector.elementAt(i) + "[\\s\\t=]+[^>]*)>", "\\&lt;!$1$2!\\&gt;"); } [/code] I have a Vector of HTML string text consisting of things like: {"i", "b", "u", "blockquote", "font"} And within this.content, which contains HTML, I want to strip out all HTML except for certain "s...

html e-mail with an & inside links --> gets converted to &amp;
Hi I've noticed that pegasus convert an & inside a hyperlink to &amp; This gives problems when there are links wich contain more than one parameter. Is there a solution for it? Alain <wco6b0f02@sneakemail.com> wrote in news:MPG.1a67d321b777844a98968d@news.telenet.be: > I've noticed that pegasus convert an & inside a hyperlink to &amp; Pegasus Mail does that? Under what circumstances? - Fred Hi Fred In article <f131382a916849aa7bdfb4584a0c7663@news.teranews.com>, fv+abuse@nospam.usen.epitools.com says... > Alain <...

'&' or '&&' ??
In an if statement which operator & or && is best to used for and? In article <fmgr8a$a5s$1@news.net.uni-c.dk>, saneman <yyyy@dd.com> wrote: >In an if statement which operator & or && is best to used for and? && if you are working with scalar values, and & if you are working with a vector. -- "I will speculate that [...] applications [...] could actually see a performance boost for most users by going dual-core [...] because it is running the adware and spyware that [...] are otherwise slowing down the single CPU that user has...

Web resources about - How can I get attribute values to not get converted from &apos; to ' or &amp; to & or &lt; to > ? - comp.text.xml

Resources last updated: 2/23/2016 7:33:00 PM