Monday, February 13, 2012

' in the output of XML Explicit

Hi,
I have got a piece of XML genereated from XML Explicit like below which
should display an apostrophe instead of '
<ITEM_DESCRIIPTION id=1 desc1="Super Wine 12's"/>
I tried to add xml directive but seems it only works for element but not
attribute.
Could somebody help me out?
Thanks very much!
Cloud
cloudx wrote:
> Hi,
> I have got a piece of XML genereated from XML Explicit like below which
> should display an apostrophe instead of '
> <ITEM_DESCRIIPTION id=1 desc1="Super Wine 12's"/>
When processed, this is exactly equivalent to a unidirectional
(typewriter-style) apostrophe. What's the problem? (Apart from the fact
that your example isn't well-formed: it needs quotes in the id="1".)
///Peter
|||"Peter Flynn" wrote:

> cloudx wrote:
> When processed, this is exactly equivalent to a unidirectional
> (typewriter-style) apostrophe. What's the problem? (Apart from the fact
> that your example isn't well-formed: it needs quotes in the id="1".)
> ///Peter
>
|||Hi Peter,
Thanks for your reply. To clearly explain the issue I am having, here is a
piece of SQL code that returns a string of XML.
Select 1as Tag,
NULLas Parent,
NULLas [PRODUCT!1],
NULLas [ITEM_DESCRIPTION!2!id],
NULLas [ITEM_DESCRIPTION!2!desc]
union
select 2,
1,
'PRODUCT'
, null
, null
union
select 2,
1,
null,
1,
'super wine 12''s'
for xml explicit
The output is:
<PRODUCT><ITEM_DESCRIPTION id="1" desc="super wine
12's"/><ITEM_DESCRIPTION/></PRODUCT>
I would like to get rid of ' and show the original '.
Thanks!
Cloud
"Peter Flynn" wrote:

> cloudx wrote:
> When processed, this is exactly equivalent to a unidirectional
> (typewriter-style) apostrophe. What's the problem? (Apart from the fact
> that your example isn't well-formed: it needs quotes in the id="1".)
> ///Peter
>
|||You can use the !xml directive
Change
NULL as [ITEM_DESCRIPTION!2!desc]
to
NULL as [ITEM_DESCRIPTION!2!desc!xml]
|||Thanks for your reply. With xml directive it only gives me desc element but I
want desc attribute.
To further explain my issue:
I understand there is no issue of displaying the XML with ' in
iexploere as it will be converted to real apostrophe, however the real issue
is that if I look at the output in say Textpad the ' is there and when I
try to validate the output against the schema, the ' occupies 6
characters and cause the maximum length exceed.
e.g. the desc is defined as 15 characters in the schema which just fits
"super wine 12's", however it will fail on "super wine 12's".
That's the issue!
Please help!
Thanks!
Cloud
"markc600@.hotmail.com" wrote:

> You can use the !xml directive
> Change
> NULL as [ITEM_DESCRIPTION!2!desc]
> to
> NULL as [ITEM_DESCRIPTION!2!desc!xml]
>
|||AFAIK, SQL Server 2000 won't let you generate unencoded
attributes (only unencoded elements using the !xml directive).
|||The validation error looks like a bug in the validator.
XML requires/allows encoding apostrophe as '. The information set value
is exactly the same as the apostrophe itself (and the validator should
accept it as such).
Having said that, SQL Server 2005 is actually returning the apostrophe as is
(and not entitized) for your query below. So you could upgrade from 2000 to
2005 ;-)
Best regards
Michael
"cloudx" <cloudx@.discussions.microsoft.com> wrote in message
news:8D8E014E-4DAB-4BAF-9D21-4C3413154B65@.microsoft.com...[vbcol=seagreen]
> Thanks for your reply. With xml directive it only gives me desc element
> but I
> want desc attribute.
> To further explain my issue:
> I understand there is no issue of displaying the XML with ' in
> iexploere as it will be converted to real apostrophe, however the real
> issue
> is that if I look at the output in say Textpad the ' is there and
> when I
> try to validate the output against the schema, the ' occupies 6
> characters and cause the maximum length exceed.
> e.g. the desc is defined as 15 characters in the schema which just fits
> "super wine 12's", however it will fail on "super wine 12's".
> That's the issue!
> Please help!
> Thanks!
> Cloud
> "markc600@.hotmail.com" wrote:
|||cloudx wrote:
> Thanks for your reply. With xml directive it only gives me desc element but I
> want desc attribute.
> To further explain my issue:
> I understand there is no issue of displaying the XML with ' in
> iexploere as it will be converted to real apostrophe, however the real issue
> is that if I look at the output in say Textpad the ' is there and when I
> try to validate the output against the schema, the ' occupies 6
> characters and cause the maximum length exceed.
> e.g. the desc is defined as 15 characters in the schema which just fits
> "super wine 12's", however it will fail on "super wine 12's".
> That's the issue!
You've got some broken software. As I said, the ' is exactly
equivalent to "'", and any XML software which treats it otherwise
is almost certainly wrong. A max length should be applied *after*
entity resolution, not before.
///Peter
XML FAQ: http://xml.silmaril.ie/

No comments:

Post a Comment