473,320 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Deserializing xml into an object using xsl:copy-of

Sample input XML...

<Publication>
<FilingMetadata>
<Id>38EA51240E6643208DB1B6D52F779A82</Id>
<Cycle>BC</Cycle>
</FilingMetadata>
<PublicationComponent Role="Main" MediaType="Text">
<TextContentItem>
<Language>en-us</Language>
<DataContent>
<nitf>
<body.content>
<block>
<p>The dollar dropped versus the yen again
Thursday, extending the sharp losses seen in recent

sessions amid a violent reversal from months of betting heavily against
the Japanese currency.</p>
<p>However, the dollar gained modestly
against the euro, helped by solid economic data and also aided by the

yen's advance versus the euro.</p>
</block>
</body.content>
</nitf>
</DataContent>
</TextContentItem>
</PublicationComponent>
<Publication>

Target Class into which I want to eventually deserialize the above
xml...

class Publication
{
public string ID; // Will contain
"38EA51240E6643208DB1B6D52F779A82"
public string Cycle; // will contain BC

public string DataContentXML;
}

This is a two-step process.

Step one is to use an xslt to transform the input into something like
this:

<TextContent>
<Id>38EA51240E6643208DB1B6D52F779A82</id>
<FullText>
<nitf>
<body.content>
<block>
<p>The dollar dropped versus the yen again
Thursday, extending the sharp losses seen in recent sessions amid a
violent

reversal from months of betting heavily against the Japanese
currency.</p>
<p>However, the dollar gained modestly
against the euro, helped by solid economic data and also aided by the

yen's advance versus the euro.</p>
</block>
</body.content>
</nitf>
</FullText>
<TextContent>

The <IDand <Cycletags works just fine.

I want to use xsl:copy-of (I think) to get all of the contents of the
<DataContenttag, including xml tags loaded into a string so that all
tags are preserved.

Xsl:copy-of is not working. All I get is "There is an error in the XML
file" with no further explanation. If I use xsl:value-of, I can get
all the text but no tags. The tags are important for later processing.

Step two will be to deserialize the xml above into an object as
outlined in the Publication class with everything between the
<FullTexttags loaded into the Publication.DataContentXML property as
one complete string, including the child tags.

I am not yet an XML or XSLT expert.

Question 1: Is this possible?
Question 2: How do I do this?

Oct 30 '06 #1
1 3180
Kenny D wrote:
Step one is to use an xslt to transform the input into something like
this:

<TextContent>
<Id>38EA51240E6643208DB1B6D52F779A82</id>
<FullText>
<nitf>
<body.content>
<block>
<p>The dollar dropped versus the yen again
Thursday, extending the sharp losses seen in recent sessions amid a
violent

reversal from months of betting heavily against the Japanese
currency.</p>
<p>However, the dollar gained modestly
against the euro, helped by solid economic data and also aided by the

yen's advance versus the euro.</p>
</block>
</body.content>
</nitf>
</FullText>
<TextContent>

The <IDand <Cycletags works just fine.

I want to use xsl:copy-of (I think) to get all of the contents of the
<DataContenttag, including xml tags loaded into a string so that all
tags are preserved.

Xsl:copy-of is not working. All I get is "There is an error in the XML
file" with no further explanation. If I use xsl:value-of, I can get
all the text but no tags. The tags are important for later processing.
Show us your XSLt stylesheet. That's hard to say why xsl:copy-of won't
work without seeing your code.

--
Oleg Tkachenko [XML MVP, MCPD]
http://blog.tkachenko.com | http://www.XmlLab.Net | http://www.XLinq.Net
Oct 31 '06 #2

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

Similar topics

1
by: Johnson, Shaunn | last post by:
Howdy: Running PostgreSQL 7.3.3 on RedHat Linux 7.2 I'm trying to load data from a text file that has an odd character in it (^@). From what I could tell, it's a NULL character. How can I...
8
by: Knighterrant | last post by:
I want to copy elements from one namespace to anothor, how to create the xslt? for example, the source data is: <s:mail xmlns:s="urn:source-namespace"> <s:subject>xxxx</s:subject>...
3
by: Johnny | last post by:
Hi, I have created an ASP.NET application (let's call it FooBar) with VS.NET on my local machine, residing in http://localhost/FooBar. Deploying it to another folder on my machine works well...
3
by: @do | last post by:
Hi! My XML File is something like this: <?xml version="1.0" encoding="ISO-8859-1"?> <item_list> <item_list_elements> <code>01600</code> <name>John</name> <text>some text ABC</text>
3
by: frjm31-groups | last post by:
Hi. I would like to explicitly allow object copy, without writting a user defined copy constructor. I am looking for something like : class C { public:
12
by: mantrid | last post by:
Im trying to move a file but am having luck my code is below. The temp and target paths are valid as they echo correctly. but I cant get the copy() function to work, or the rename() function ...
9
by: Paulo Matos | last post by:
Hi all, Given a list of int, it's rather easy to output them line by line: std::copy(mylist.begin(), mylist.end(), std::ostream_iterator<int>(cout, "\n"); Now, there's two ways in which I...
3
by: Andy Dingley | last post by:
>From a thread over in c.i.w.a.h "RFC: From XHTML to HTML via XSLT" http://groups.google.co.uk/group/comp.infosystems.www.authoring.html/msg/f112c230061ffe86 As is well-known, the XSLT HTML...
0
by: geethagovindarajan | last post by:
Can any one help me out with coding for object copy in C#.Net
7
by: Jeffrey Barish | last post by:
(Pdb) myclass MyClass( 0, 0, 'A string', 123.45) (Pdb) copy.copy(myclass) *** TypeError: TypeError('__new__() takes at least 4 arguments (2 given)',) I see 4 arguments (actually, 5 because...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.