473,408 Members | 2,477 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,408 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 1136

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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.