XSL and transformNodeToObject

mtugnoli

Usenet Archive
Joined
Mar 27, 2007
Messages
2
Reaction score
0
I've found a sample on http://msdn2.microsoft.com/en-us/library/ms766561.aspx

to filter a .XML
ex.

<?xml version="1.0"?>
<COLLECTION dateCreated="01-04-2000">
<BOOK>
<TITLE>Splish Splash</TITLE>
<AUTHOR>Paula Thurman</AUTHOR>
<PUBLISHER>Scootney</PUBLISHER>
<PRICE>250</PRICE>
</BOOK>
<BOOK>
<TITLE Editor="Hoepli">Lover Birds2</TITLE>
<AUTHOR>Cynthia Randall</AUTHOR>
<PUBLISHER>Lucerne Publishing</PUBLISHER>
<PRICE>200</PRICE>
</BOOK>
<BOOK>
<TITLE>The Sundered Grail</TITLE>
<AUTHOR>Eva Corets</AUTHOR>
<PUBLISHER>Lucerne Publishing</PUBLISHER>
<PRICE>100</PRICE>
</BOOK>
</COLLECTION>

file .xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform"> <xsl:template match="/"> <LowPriceBooks> <xsl:for-each select="//COLLECTION/BOOK[not(PRICE >'220')]"> <xsl:copy> <xsl:apply-templates select="*"/> </xsl:copy> </xsl:for-each> </LowPriceBooks> </xsl:template> <xsl:template match="*"> <xsl:copy> <xsl:apply-templates /> </xsl:copy> </xsl:template> </xsl:stylesheet>

the essential part on VB

' Parse results into a result DOM Document.
Source.transformNodeToObject stylesheet, result

where Source is not filtred .XML and stylesheet is .xsl file where result is .XML processed (filtred) with PRICE > 220

considering I don't know very well XML,

All work fine but after the processing the node

<TITLE Editor="Hoepli">Lover Birds2</TITLE>

the property Editor="Hoepli" is lost !!

can I change the .xls file to copy also properties ?

I hope someone can help me ..

mtugnoli
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
mtugnoli said:
<xsl:template match="/">
<LowPriceBooks>
<xsl:for-each select="//COLLECTION/BOOK[not(PRICE >'220')]"> <xsl:copy> <xsl:apply-templates select="*"/> </xsl:copy> </xsl:for-each>

Instead of the xsl:for-each simply use

</LowPriceBooks>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>

then instead of the above template use

<xsl:template match="@* | node">
<xsl:copy>
<xsl:apply-templates select="@* | node"/>
</xsl:copy>
</xsl:template>

that way the attributes get copied too.
 

mtugnoli

Usenet Archive
Joined
Mar 27, 2007
Messages
2
Reaction score
0
mtugnoli said:
<xsl:template match="/">
<LowPriceBooks>
<xsl:for-each select="//COLLECTION/BOOK[not(PRICE >'220')]"> <xsl:copy> <xsl:apply-templates select="*"/> </xsl:copy> </xsl:for-each>

Instead of the xsl:for-each simply use

</LowPriceBooks>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>

then instead of the above template use

<xsl:template match="@* | node">
<xsl:copy>
<xsl:apply-templates select="@* | node"/>
</xsl:copy>
</xsl:template>

that way the attributes get copied too.

Hey Martin,

All run Ok

Thank for your Help

mtugnoli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,050
Messages
3,104,249
Members
248,133
Latest member
DujonT

Latest Threads

Top