Showing posts with label header. Show all posts
Showing posts with label header. Show all posts

Monday, March 19, 2012

Missing XML header that specifies the encoding

Hello,
In my solution I ned the xml output with including the XML header thet
specifies the encoding.
Here's the code:
CREATE XML SCHEMA COLLECTION MyNote AS
N'<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com" xmlns="http://
www.w3schools.com" elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="HedingType" type="xs:string"/>
</xs:schema>'
GO
then input a valid xml
DECLARE @.x xml (dbo.MyNote)
SET @.x=N'<note xmlns="http://www.w3schools.com">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this wend!</body>
</note>'
select @.x
Here's the output:
<note xmlns="http://www.w3schools.com">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this wend!</body>
</note>
I need the XML header that specify the encoding of the document, like
this:
<?xml version="1.0" encoding="UTF-8"?>
<note xmlns="http://www.w3schools.com">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this wend!</body>
</note>
Any ideas?
Thanks in advance!
JohnWell the heading is optional for UTF-8 documents. The heading's only useful
for serialised documents, how are you using the output?
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
"johnk" <johnk_hansen@.hotmail.com> wrote in message
news:1170427960.566676.200010@.s48g2000cws.googlegroups.com...
> Hello,
> In my solution I ned the xml output with including the XML header thet
> specifies the encoding.
> Here's the code:
> CREATE XML SCHEMA COLLECTION MyNote AS
> N'<?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.w3schools.com" xmlns="http://
> www.w3schools.com" elementFormDefault="qualified">
> <xs:element name="note">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="to" type="xs:string"/>
> <xs:element name="from" type="xs:string"/>
> <xs:element name="heading" type="xs:string"/>
> <xs:element name="body" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="HedingType" type="xs:string"/>
> </xs:schema>'
> GO
> then input a valid xml
> DECLARE @.x xml (dbo.MyNote)
> SET @.x=N'<note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this wend!</body>
> </note>'
> select @.x
> Here's the output:
> <note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this wend!</body>
> </note>
> I need the XML header that specify the encoding of the document, like
> this:
> <?xml version="1.0" encoding="UTF-8"?>
> <note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this wend!</body>
> </note>
> Any ideas?
>
> Thanks in advance!
> John
>|||On 2 Feb, 17:46, "Joe Fawcett" <joefawc...@.newsgroup.nospam> wrote:
> Well the heading is optional for UTF-8 documents. The heading's only usefu
l
> for serialised documents, how are you using the output?
> --
> Joe Fawcett (MVP - XML)http://joe.fawcett.name
> "johnk" <johnk_han...@.hotmail.com> wrote in message
> news:1170427960.566676.200010@.s48g2000cws.googlegroups.com...
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> - Vis sitert tekst -
I am using the query window in MS SQL Server Management Studio .|||John,
The processing instruction specifies the encoding when the XML is stored as
text. When you store an instance in an XML datatype, it is not stored as tex
t
but in binary XML format. Therefore, what's the point of specifying an XML
encoding? It would have no meaning.
In your case, I would suggest you convert your XML instance to a string type
and
add the processing instruction trhough string manipulation. You can do somet
hing
like this
DECLARE @.x xml (dbo.MyNote)
DECLARE @.strXML varchar(MAX)
SET @.x=N'<note xmlns="http://www.w3schools.com">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this wend!</body>
</note>'
set @.strXML = '<?xml version="1.0" encoding="UTF-8"?>' + CONVERT(varchar(MAX
),
@.x)
SELECT @.strXML
While we're talking about encoding of XML documents I've also noticed someth
ing
strange in your example. When you create your schema collection you do this
CREATE XML SCHEMA COLLECTION MyNote AS
N'<?xml version="1.0" encoding="UTF-8"?>
....
'
go
The string literal is unicode (because of the 'N' character that preceeds it
)
but yet you specify the encoding as UTF-8 in your processing instruction. Th
e
DDL as you've written it should fail with the following error: "XML parsing:
line 1, character 38, unable to switch the encoding"
Denis Ruckebusch
http://blogs.msdn.com/denisruc
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"johnk" <johnk_hansen@.hotmail.com> wrote in message
news:1170427960.566676.200010@.s48g2000cws.googlegroups.com...
> Hello,
> In my solution I ned the xml output with including the XML header thet
> specifies the encoding.
> Here's the code:
> CREATE XML SCHEMA COLLECTION MyNote AS
> N'<?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.w3schools.com" xmlns="http://
> www.w3schools.com" elementFormDefault="qualified">
> <xs:element name="note">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="to" type="xs:string"/>
> <xs:element name="from" type="xs:string"/>
> <xs:element name="heading" type="xs:string"/>
> <xs:element name="body" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="HedingType" type="xs:string"/>
> </xs:schema>'
> GO
> then input a valid xml
> DECLARE @.x xml (dbo.MyNote)
> SET @.x=N'<note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this wend!</body>
> </note>'
> select @.x
> Here's the output:
> <note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this wend!</body>
> </note>
> I need the XML header that specify the encoding of the document, like
> this:
> <?xml version="1.0" encoding="UTF-8"?>
> <note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this wend!</body>
> </note>
> Any ideas?
>
> Thanks in advance!
> John
>|||In addition to Denis' post: You cannot get UTF-8 encoded XML data produced.
SQL Server produces UTF-16 encoded XML when you cast it to
NVARCHAR/VARBINARY, or the encoding of the code page if you cast to
VARCHAR(not recommended).
Since the NVARCHAR/VARCHAR carries the encoding on the type, we do not add
an XML declaration with an encoding, so that if you cast your string to a
different collation, the encoding does get adjusted automatically.
Now if you cast it to VARBINARY we will add the UTF-16 BOM.
If you want to produce UTF-8 encoded XML or have the XML declaration added,
you probably should use the System.XML or MSXML components on the
client/midtier side.
Best regards
Michael
"johnk" <johnk_hansen@.hotmail.com> wrote in message
news:1170439250.695037.296940@.q2g2000cwa.googlegroups.com...
> On 2 Feb, 17:46, "Joe Fawcett" <joefawc...@.newsgroup.nospam> wrote:
> I am using the query window in MS SQL Server Management Studio .
>

Missing XML header that specifies the encoding

Hello,
In my solution I ned the xml output with including the XML header thet
specifies the encoding.
Here's the code:
CREATE XML SCHEMA COLLECTION MyNote AS
N'<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com" xmlns="http://
www.w3schools.com" elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="HedingType" type="xs:string"/>
</xs:schema>'
GO
then input a valid xml
DECLARE @.x xml (dbo.MyNote)
SET @.x=N'<note xmlns="http://www.w3schools.com">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>'
select @.x
Here's the output:
<note xmlns="http://www.w3schools.com">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
I need the XML header that specify the encoding of the document, like
this:
<?xml version="1.0" encoding="UTF-8"?>
<note xmlns="http://www.w3schools.com">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Any ideas?
Thanks in advance!
John
Well the heading is optional for UTF-8 documents. The heading's only useful
for serialised documents, how are you using the output?
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
"johnk" <johnk_hansen@.hotmail.com> wrote in message
news:1170427960.566676.200010@.s48g2000cws.googlegr oups.com...
> Hello,
> In my solution I ned the xml output with including the XML header thet
> specifies the encoding.
> Here's the code:
> CREATE XML SCHEMA COLLECTION MyNote AS
> N'<?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.w3schools.com" xmlns="http://
> www.w3schools.com" elementFormDefault="qualified">
> <xs:element name="note">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="to" type="xs:string"/>
> <xs:element name="from" type="xs:string"/>
> <xs:element name="heading" type="xs:string"/>
> <xs:element name="body" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="HedingType" type="xs:string"/>
> </xs:schema>'
> GO
> then input a valid xml
> DECLARE @.x xml (dbo.MyNote)
> SET @.x=N'<note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this weekend!</body>
> </note>'
> select @.x
> Here's the output:
> <note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this weekend!</body>
> </note>
> I need the XML header that specify the encoding of the document, like
> this:
> <?xml version="1.0" encoding="UTF-8"?>
> <note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this weekend!</body>
> </note>
> Any ideas?
>
> Thanks in advance!
> John
>
|||On 2 Feb, 17:46, "Joe Fawcett" <joefawc...@.newsgroup.nospam> wrote:
> Well the heading is optional for UTF-8 documents. The heading's only useful
> for serialised documents, how are you using the output?
> --
> Joe Fawcett (MVP - XML)http://joe.fawcett.name
> "johnk" <johnk_han...@.hotmail.com> wrote in message
> news:1170427960.566676.200010@.s48g2000cws.googlegr oups.com...
>
>
>
>
>
>
>
>
> - Vis sitert tekst -
I am using the query window in MS SQL Server Management Studio .
|||John,
The processing instruction specifies the encoding when the XML is stored as
text. When you store an instance in an XML datatype, it is not stored as text
but in binary XML format. Therefore, what's the point of specifying an XML
encoding? It would have no meaning.
In your case, I would suggest you convert your XML instance to a string type and
add the processing instruction trhough string manipulation. You can do something
like this
DECLARE @.x xml (dbo.MyNote)
DECLARE @.strXML varchar(MAX)
SET @.x=N'<note xmlns="http://www.w3schools.com">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>'
set @.strXML = '<?xml version="1.0" encoding="UTF-8"?>' + CONVERT(varchar(MAX),
@.x)
SELECT @.strXML
While we're talking about encoding of XML documents I've also noticed something
strange in your example. When you create your schema collection you do this
CREATE XML SCHEMA COLLECTION MyNote AS
N'<?xml version="1.0" encoding="UTF-8"?>
.....
'
go
The string literal is unicode (because of the 'N' character that preceeds it)
but yet you specify the encoding as UTF-8 in your processing instruction. The
DDL as you've written it should fail with the following error: "XML parsing:
line 1, character 38, unable to switch the encoding"
Denis Ruckebusch
http://blogs.msdn.com/denisruc
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"johnk" <johnk_hansen@.hotmail.com> wrote in message
news:1170427960.566676.200010@.s48g2000cws.googlegr oups.com...
> Hello,
> In my solution I ned the xml output with including the XML header thet
> specifies the encoding.
> Here's the code:
> CREATE XML SCHEMA COLLECTION MyNote AS
> N'<?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.w3schools.com" xmlns="http://
> www.w3schools.com" elementFormDefault="qualified">
> <xs:element name="note">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="to" type="xs:string"/>
> <xs:element name="from" type="xs:string"/>
> <xs:element name="heading" type="xs:string"/>
> <xs:element name="body" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="HedingType" type="xs:string"/>
> </xs:schema>'
> GO
> then input a valid xml
> DECLARE @.x xml (dbo.MyNote)
> SET @.x=N'<note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this weekend!</body>
> </note>'
> select @.x
> Here's the output:
> <note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this weekend!</body>
> </note>
> I need the XML header that specify the encoding of the document, like
> this:
> <?xml version="1.0" encoding="UTF-8"?>
> <note xmlns="http://www.w3schools.com">
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this weekend!</body>
> </note>
> Any ideas?
>
> Thanks in advance!
> John
>
|||In addition to Denis' post: You cannot get UTF-8 encoded XML data produced.
SQL Server produces UTF-16 encoded XML when you cast it to
NVARCHAR/VARBINARY, or the encoding of the code page if you cast to
VARCHAR(not recommended).
Since the NVARCHAR/VARCHAR carries the encoding on the type, we do not add
an XML declaration with an encoding, so that if you cast your string to a
different collation, the encoding does get adjusted automatically.
Now if you cast it to VARBINARY we will add the UTF-16 BOM.
If you want to produce UTF-8 encoded XML or have the XML declaration added,
you probably should use the System.XML or MSXML components on the
client/midtier side.
Best regards
Michael
"johnk" <johnk_hansen@.hotmail.com> wrote in message
news:1170439250.695037.296940@.q2g2000cwa.googlegro ups.com...
> On 2 Feb, 17:46, "Joe Fawcett" <joefawc...@.newsgroup.nospam> wrote:
> I am using the query window in MS SQL Server Management Studio .
>

Friday, March 9, 2012

Missing Row in CSV Export

Hi Everyone,
I'm having an issue with a row of data missing when exporting to CSV.
The report structure is as follows:
Group 1 Header - Grouping on State (Displays the State)
Group 2 Header - Grouping on Customer ID (Displays a summary for each
customer)
Detail Row - <This Row has Been Removed>
Group 2 Footer - <This Row has Been Removed>
Group 1 Footer - Displays totals for the state
The report renders fine to PDF and will export all data to XML. When I
export to CSV, the first row is always missing. I have two reports with
similar structure and suffers from the same issue.
Any help would be greatly appreciated.
Thanks
ChadIf you add rectangle/ blank image / blank label above your report, CSV export
will work.
"Chad McKee" wrote:
> Hi Everyone,
> I'm having an issue with a row of data missing when exporting to CSV.
> The report structure is as follows:
> Group 1 Header - Grouping on State (Displays the State)
> Group 2 Header - Grouping on Customer ID (Displays a summary for each
> customer)
> Detail Row - <This Row has Been Removed>
> Group 2 Footer - <This Row has Been Removed>
> Group 1 Footer - Displays totals for the state
> The report renders fine to PDF and will export all data to XML. When I
> export to CSV, the first row is always missing. I have two reports with
> similar structure and suffers from the same issue.
> Any help would be greatly appreciated.
> Thanks
> Chad
>|||We have posted a hotfix that includes a fix for this issue at
http://www.microsoft.com/downloads/details.aspx?FamilyId=7FFE50D4-AFF8-4C1E-9609-6798190C2D58&displaylang=en.
--
Brian Welcker
Group Program Manager
Microsoft SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
"Chad McKee" <cmckee@.startech-comp.com> wrote in message
news:%2340961OeFHA.3048@.TK2MSFTNGP12.phx.gbl...
> Hi Everyone,
> I'm having an issue with a row of data missing when exporting to CSV. The
> report structure is as follows:
> Group 1 Header - Grouping on State (Displays the State)
> Group 2 Header - Grouping on Customer ID (Displays a summary for each
> customer)
> Detail Row - <This Row has Been Removed>
> Group 2 Footer - <This Row has Been Removed>
> Group 1 Footer - Displays totals for the state
> The report renders fine to PDF and will export all data to XML. When I
> export to CSV, the first row is always missing. I have two reports with
> similar structure and suffers from the same issue.
> Any help would be greatly appreciated.
> Thanks
> Chad|||> The report renders fine to PDF and will export all data to XML. When I
> export to CSV, the first row is always missing. I have two reports with
> similar structure and suffers from the same issue.
Hmm, haven't looked into the problem but maybe the CSV export is getting
confused with header rows. In case you just can't find a work-around, a
custom CSV rendering extension might be the solution. I imagine that
shouldn't be too hard to accomplish.
Christoph|||Thanks to everyone who replied. The Hotfix fixed the issue.
Thanks
Chad
Brian Welcker [MSFT] wrote:
> We have posted a hotfix that includes a fix for this issue at
> http://www.microsoft.com/downloads/details.aspx?FamilyId=7FFE50D4-AFF8-4C1E-9609-6798190C2D58&displaylang=en.
>

Saturday, February 25, 2012

Missing Header Footer in

Hey all-

We have a number of reports that have headers and footers in HTML and PDF, but when exporting to Excel the headers and footers disappear.

Has anyone else seen this happen? Any ideas on how to re-enable the headers?

Thanks in advance,

Tristan

Tristan, did you find a way to do this? I am in a very similar position where the footers are not displayed.

Thanks,
AJ