 |
|
 |
|
Next: Tracking of changes
|
| Author |
Message |
External

Since: Jan 05, 2007 Posts: 2
|
(Msg. 1) Posted: Thu Jun 24, 2010 11:52 am
Post subject: XML - Eliminate Namespace in Elements Archived from groups: microsoft>public>sqlserver>programming (more info?)
|
|
|
I have created a stored procedure that generates an XML file. The only issue
is that the namespace is being duplicated in each of the detail elements and
I only want it to appear in the root. I am including my code and any help
would be greatly appreciated!
TIA, Mary
This is just a brief display of what I am trying to produce .....
<submission namespace data .....>
<header_record>
detail elements
</header_record>
<detail_record ID="123">
detail elements
</detail_record>
<detail_record ID="124">
detail elements
</detail_record>
</submission>
;WITH XMLNAMESPACES (
DEFAULT 'http://www.wisconsinedi.org',
'http://www.wisconsinedi.org' as "fc",
'http://www.w3.org/2001/XMLSchema-instance' as "xsi")
SELECT
(SELECT
submitter_organization_id,
CONVERT(varchar(10), GETDATE(), 20) AS submission_date,
@StartDate AS begin_posting_date,
@EndDate AS end_posting_date,
COUNT(record_id) AS number_of_records_transmitted
FROM dbo.vw_EncounterAll AS header_record
WHERE posting_date BETWEEN @StartDate And @EndDate
GROUP BY submitter_organization_id
FOR XML PATH('header_record'), TYPE),
(SELECT
record_id AS "@ID",
billing_provider_last_name,
billing_provider_first_name,
adjustment_type,
billing_provider_id,
billing_provider_id_qualifier,
charges,
claim_status,
data_source,
member_share,
medicare_paid_amount,
original_id,
other_payer_paid_amount_primary,
other_payer_paid_amount_secondary,
paid_amount,
parent_record_id,
place_of_service,
procedure_code,
quantity,
posting_date,
reciept_date,
recipient_death_date,
recipient_first_name,
recipient_last_name,
recipient_id,
record_type,
service_date_from,
service_date_to,
spc,
submitter_organization_id,
support_indicator,
unit_or_basis_for_measurement_code
FROM vw_EncounterAll AS detail_record WHERE BatchID = @BatchID
FOR XML PATH ('detail_record'), TYPE)
FOR XML PATH(''), ROOT('submission'), TYPE >> Stay informed about: XML - Eliminate Namespace in Elements |
|
| Back to top |
|
 |  |
External

Since: May 30, 2004 Posts: 2061
|
(Msg. 2) Posted: Thu Jun 24, 2010 6:25 pm
Post subject: Re: XML - Eliminate Namespace in Elements [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Mary (mary@lifetimeinc.com) writes:
> I have created a stored procedure that generates an XML file. The only
> issue is that the namespace is being duplicated in each of the detail
> elements and I only want it to appear in the root. I am including my
> code and any help would be greatly appreciated!
>
> TIA, Mary
>
> This is just a brief display of what I am trying to produce .....
>
><submission namespace data .....>
>
> <header_record>
> detail elements
> </header_record>
>
> <detail_record ID="123">
> detail elements
> </detail_record>
> <detail_record ID="124">
> detail elements
> </detail_record>
>
></submission>
This is not an area that I know too well. But by putting the inner
XML documents in variable, I was able to reduce the presence of the
namespaces in the inner nodes, but not elimiate it:
declare @x1 xml, @x2 xml
SELECT @x1 =
(SELECT OrderID, OrderDate, CustomerID
FROM Orders
WHERE OrderID = 11000
FOR XML PATH('header_record'), TYPE),
@x2 =
(SELECT OrderID AS "@ID", ProductID, Quantity
FROM [Order Details]
WHERE OrderID = 11000
FOR XML PATH('detail_record'), TYPE)
;WITH XMLNAMESPACES (
DEFAULT 'http://www.wisconsinedi.org',
'http://www.wisconsinedi.org' as "fc",
'http://www.w3.org/2001/XMLSchema-instance' as "xsi")
SELECT @x1, @x2
FOR XML PATH(''), ROOT('submission')
--
Erland Sommarskog, SQL Server MVP, esquel.RemoveThis@sommarskog.se
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx >> Stay informed about: XML - Eliminate Namespace in Elements |
|
| Back to top |
|
 |  |
External

Since: Jan 11, 2008 Posts: 157
|
(Msg. 3) Posted: Fri Jun 25, 2010 4:25 am
Post subject: Re: XML - Eliminate Namespace in Elements [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Thu, 24 Jun 2010 11:52:01 -0500, "Mary"
wrote:
>I have created a stored procedure that generates an XML file. The only issue
>is that the namespace is being duplicated in each of the detail elements and
>I only want it to appear in the root. I am including my code and any help
>would be greatly appreciated!
>
>TIA, Mary
>
>This is just a brief display of what I am trying to produce .....
>
><submission namespace data .....>
>
> <header_record>
> detail elements
> </header_record>
>
> <detail_record ID="123">
> detail elements
> </detail_record>
> <detail_record ID="124">
> detail elements
> </detail_record>
>
></submission>
>
>
>
> ;WITH XMLNAMESPACES (
> DEFAULT 'http://www.wisconsinedi.org',
> 'http://www.wisconsinedi.org' as "fc",
> 'http://www.w3.org/2001/XMLSchema-instance' as "xsi")
>
>
> SELECT
>
> (SELECT
> submitter_organization_id,
> CONVERT(varchar(10), GETDATE(), 20) AS submission_date,
> @StartDate AS begin_posting_date,
> @EndDate AS end_posting_date,
> COUNT(record_id) AS number_of_records_transmitted
>
> FROM dbo.vw_EncounterAll AS header_record
> WHERE posting_date BETWEEN @StartDate And @EndDate
> GROUP BY submitter_organization_id
> FOR XML PATH('header_record'), TYPE),
>
> (SELECT
> record_id AS "@ID",
> billing_provider_last_name,
> billing_provider_first_name,
> adjustment_type,
> billing_provider_id,
> billing_provider_id_qualifier,
> charges,
> claim_status,
> data_source,
> member_share,
> medicare_paid_amount,
> original_id,
> other_payer_paid_amount_primary,
> other_payer_paid_amount_secondary,
> paid_amount,
> parent_record_id,
> place_of_service,
> procedure_code,
> quantity,
> posting_date,
> reciept_date,
> recipient_death_date,
> recipient_first_name,
> recipient_last_name,
> recipient_id,
> record_type,
> service_date_from,
> service_date_to,
> spc,
> submitter_organization_id,
> support_indicator,
> unit_or_basis_for_measurement_code
>
> FROM vw_EncounterAll AS detail_record WHERE BatchID = @BatchID
> FOR XML PATH ('detail_record'), TYPE)
>
> FOR XML PATH(''), ROOT('submission'), TYPE
>
Along with Erlands response you seem to be seeing the same effect as
described in
https://connect.microsoft.com/SQLServer/feedback/details/265956/suppre...namespa
The XML should still be valid even though the re-declaration of the
namespaces is not necessary.
John >> Stay informed about: XML - Eliminate Namespace in Elements |
|
| Back to top |
|
 |  |
| Related Topics: | Eliminate the duplicated records - Hi, I have there tables user, holding, and book. The user table contains all user information, primary key is userID, the book table contains all info of books, the primary key is bookID, the holding is a join table for user and book that has primary...
Eliminate character from string ? - Is there a quick and easy way to remove a given character from a string? e.g. to convert O'Neill to ONeill Thanks.
Restricting output of view to eliminate rows having duplic.. - Hi, I got the output from a view as following: Part# Project# ModDate Status 100-1 100A 01/10/08 A 150-2 200B 02/10/08 A 100-1 199K 02/10/08 A 100-1 198P 03/09/08 A 200-4 100T 04/12/08 A 200-4 100...
SQLXMLBulkLoad: how to build schema to join elements - How would I modify the xsd schema below, to load from xml data file into sql server table using SQLXMLBulkLoad insert into table as shown below. I can do it with two schemas, but I'm sure it can be done with one. And, I almost have it right using..
Commas between address elements and the COALESCE function - Hi Group, I've got the following select statement, however the addressnew value comes out without commas between each element of the address. How can I separate each element of the address with a comma ? ('SELECT applicant.surname + '', '' +.. |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|