473,322 Members | 1,718 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,322 software developers and data experts.

.NET and XSLT id()

I must be an idiot because I STILL cannot coax .NET to
successfully execute a transform which uses the XSLT id()
function. Here's the bare-bones code:

XmlValidatingReader xvr = new XmlValidatingReader(
new XmlTextReader( @"s:\data\test.xml",
new NameTable() ) );
xvr.EntityHandling = EntityHandling.ExpandEntities;
xvr.ValidationType = ValidationType.Schema;

xvr.ValidationEventHandler +=
new ValidationEventHandler( this.veh );
// this.veh() simply echos any validation errors.

XslTransform xsl = new XslTransform();
xsl.Load( @"s:\data\test.xsl" );

XPathDocument doc = new XPathDocument( xvr );

XmlDocument xml = new XmlDocument();
xml.Load( xsl.Transform( doc, xArgs,
new XmlUrlResolver() ) );
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.xml
<mydata xsi:noNamespaceSchemaLocation="test.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
<items>
<file id="F001" title="abc" size="123"/>
<file id="F002" title="xyz" size="789"/>
<notification id="PINK" title="Pink Flowers"/>
</items>
</mydata>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"
encoding="ISO-8859-1" />
<xsl:template match="/">
<results>
<by-id>
<xsl:copy-of select="id('PINK')"/>
</by-id>
<by-expression>
<xsl:copy-of select="//*
[@id='PINK']"/>
</by-expression>
</results>
</xsl:template>
</xsl:stylesheet>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm amazed at how much effort I've expended to get this
working since it was SO SIMPLE with MSXML 4 in WSH (or
ASP):

<job>
<script language="JavaScript">
{
var xml = getXml( "s:\\data\\test.xml" );
var xsl = getXml( "s:\\data\\test.xsl" );

if (xml != null && xsl != null)
{
WScript.echo( xml.transformNode( xsl ) );
}
}

function getXml( path )
{
var xml = new ActiveXObject
( "Msxml2.FreeThreadedDOMDocument.4.0" );

xml.setProperty( "SelectionLanguage", "XPath" );
xml.async = false;
xml.resolveExternals = true;
xml.load( path );
if (xml.parseError.errorCode != 0)
{
var e = xml.parseError;
WScript.echo( e.errorCode + " - "+ e.reason + "\n" +
+ e.url + " line " + e.line + ", char "+ e.linepos
+ "\n" + e.srcText );
return null;
}
return xml;
}
</script>
</job>

Pulling my hair out...
Antonio Collins
Nov 11 '05 #1
0 803

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

Similar topics

2
by: ted | last post by:
Was wondering if XSLT alone is appropriate for the following situation. From XML, I'm creating a small website (around 50 pages) with pages that link to each other through a nav menu and a...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
8
by: Maciej Wegorkiewicz | last post by:
Hi, I have small experience in XSLT processing and I have a problem which I cannot solve. Can you look at it? I have an input file containing info about bank accounts like this: (...) <acc...
12
by: gipsy boy | last post by:
Hello, I have sort of a big problem. I would really appreciate any help you could give me. I made a web service in C++ that throws XML to the client (browser). But, the XSLT transormation...
0
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag,...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
0
by: DAnne | last post by:
Hi, I'm very new to xslt and this is my first time posting to a Forum so please forgive me if I transgress any protocols. I have to do a tally report. This report is divided up into sections....
2
by: Jonny B | last post by:
Hi all, I'm working on an a clientside xslt using jscript that passes a parameter to the xsl. I've got it working no problem in IE but cant get it to work in Mozilla. Can anyone help? This is...
1
by: CAM123 | last post by:
I have added: <br><xsl:value-of select="Line" /></br> to my XSLT stylesheet to get a line per repeating block. When I view the output as XML it looks perfect - one line per block. However...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: 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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.