Veryfing XPath expressions inside XSTL document

Hi,

I have following situation:
1. Set of classes compiled to classes.dll
2. classes.xsd generated from classes.dll using xsd.exe
3. Set of XSLT documents with a lot of XPath expressions referencing
types from classes.dll

....and following problem:
When someone changes type A that is referenced in XSLT document (for
example renames a field) the classes.xsd is regenerated and there is
no build issues in my project. Furthermore even xslt transformations
are performed without errors (only the final pdf does not look like
expected).

Is there any way to check whether XPath expressions are still valid. I
would like to include such a check in build process.

M.
0
Marcin
12/11/2009 11:02:35 AM
dotnet.xml 7266 articles. 0 followers. Follow

7 Replies
1895 Views

Similar Articles

[PageSpeed] 56

Marcin Ochocki wrote:
> Hi,
> 
> I have following situation:
> 1. Set of classes compiled to classes.dll
> 2. classes.xsd generated from classes.dll using xsd.exe
> 3. Set of XSLT documents with a lot of XPath expressions referencing
> types from classes.dll
> 
> ...and following problem:
> When someone changes type A that is referenced in XSLT document (for
> example renames a field) the classes.xsd is regenerated and there is
> no build issues in my project. Furthermore even xslt transformations
> are performed without errors (only the final pdf does not look like
> expected).
> 
> Is there any way to check whether XPath expressions are still valid. I
> would like to include such a check in build process.

I am not sure I understand what you call a "valid XPath expression". If 
it is syntactically correct then e.g. /root/foo/bar is a valid 
expression, whether the XML input you want to use that XPath against 
does have a 'bar' element or not does not matter, at least not in XPath 1.0.

The only issue that I can think of: depending on how you write your XSLT 
you could consider to insert a template matching all not otherwise 
processed elements and output some warning if that happens.


-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
Martin
12/11/2009 12:03:15 PM
By valid I mean 'still existing'. For example if I have a class
class Customer
{
public string name;
//....
}

and in xslt I have XPath expression Customer/name.

Then someone changes "public string name" to "public string CustName".
Project still compiles and there is no schema validation errors (I
perform xsd checks before transformation), as xsd is generated form
the code. But customer name is not shown on the printout.

M.

On 11 Gru, 13:03, Martin Honnen <mahotr...@yahoo.de> wrote:
> Marcin Ochocki wrote:
> > Hi,
>
> > I have following situation:
> > 1. Set of classes compiled to classes.dll
> > 2. classes.xsd generated from classes.dll using xsd.exe
> > 3. Set of XSLT documents with a lot of XPath expressions referencing
> > types from classes.dll
>
> > ...and following problem:
> > When someone changes type A that is referenced in XSLT document (for
> > example renames a field) the classes.xsd is regenerated and there is
> > no build issues in my project. Furthermore even xslt transformations
> > are performed without errors (only the final pdf does not look like
> > expected).
>
> > Is there any way to check whether XPath expressions are still valid. I
> > would like to include such a check in build process.
>
> I am not sure I understand what you call a "valid XPath expression". If
> it is syntactically correct then e.g. /root/foo/bar is a valid
> expression, whether the XML input you want to use that XPath against
> does have a 'bar' element or not does not matter, at least not in XPath 1=
..0.
>
> The only issue that I can think of: depending on how you write your XSLT
> you could consider to insert a template matching all not otherwise
> processed elements and output some warning if that happens.
>
> --
>
> =A0 =A0 =A0 =A0 Martin Honnen --- MVP XML
> =A0 =A0 =A0 =A0http://msmvps.com/blogs/martin_honnen/

0
Marcin
12/11/2009 3:25:42 PM
By valid I mean 'still existing'. For example if I have a class
class Customer
{
public string name;
//....
}

and in xslt I have XPath expression Customer/name.

Then someone changes "public string name" to "public string CustName".
Project still compiles and there is no schema validation errors (I
perform xsd checks before transformation), as xsd is generated form
the code. But customer name is not shown on the printout.

M.

On 11 Gru, 13:03, Martin Honnen <mahotr...@yahoo.de> wrote:
> Marcin Ochocki wrote:
> > Hi,
>
> > I have following situation:
> > 1. Set of classes compiled to classes.dll
> > 2. classes.xsd generated from classes.dll using xsd.exe
> > 3. Set of XSLT documents with a lot of XPath expressions referencing
> > types from classes.dll
>
> > ...and following problem:
> > When someone changes type A that is referenced in XSLT document (for
> > example renames a field) the classes.xsd is regenerated and there is
> > no build issues in my project. Furthermore even xslt transformations
> > are performed without errors (only the final pdf does not look like
> > expected).
>
> > Is there any way to check whether XPath expressions are still valid. I
> > would like to include such a check in build process.
>
> I am not sure I understand what you call a "valid XPath expression". If
> it is syntactically correct then e.g. /root/foo/bar is a valid
> expression, whether the XML input you want to use that XPath against
> does have a 'bar' element or not does not matter, at least not in XPath 1=
..0.
>
> The only issue that I can think of: depending on how you write your XSLT
> you could consider to insert a template matching all not otherwise
> processed elements and output some warning if that happens.
>
> --
>
> =A0 =A0 =A0 =A0 Martin Honnen --- MVP XML
> =A0 =A0 =A0 =A0http://msmvps.com/blogs/martin_honnen/

0
Marcin
12/11/2009 3:26:11 PM
Marcin Ochocki wrote:
> By valid I mean 'still existing'. For example if I have a class
> class Customer
> {
> public string name;
> //....
> }
> 
> and in xslt I have XPath expression Customer/name.
> 
> Then someone changes "public string name" to "public string CustName".
> Project still compiles and there is no schema validation errors (I
> perform xsd checks before transformation), as xsd is generated form
> the code. But customer name is not shown on the printout.

I don't think there is an easy way with XSLT/XPath 1.0. You would need 
to implement your own checks or implement your own solution that ensures 
  your XSLT has the correct element and attribute names matching the 
definitions in your schema.

If you move to schema aware XSLT 2.0 as implemented by Saxon 9 
(http://www.saxonica.com/) then you might get assistance from the XSLT 
processor warning you that certain expressions will never find nodes 
with a certain input schema present.



-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
Martin
12/11/2009 4:39:27 PM
Hi,

I downloaded saxonhe9-2-0-3n.zip, changed <xsl:stylesheet
version=3D"1.0" to <xsl:stylesheet version=3D"2.0" in my xslt file and ran
bin\Transform.exe tool.
But the result for the changed XPath expression (I renamed a field -
so it does not exist in xml) is the same - xslt  engine just renders
empty field.

So does XSLT2.0 (Saxon?) really can validate misspelled XPath
expressions? Is it possible?

M.

On 11 Gru, 17:39, Martin Honnen <mahotr...@yahoo.de> wrote:
> Marcin Ochocki wrote:
> > By valid I mean 'still existing'. For example if I have a class
> > class Customer
> > {
> > public string name;
> > //....
> > }
>
> > and in xslt I have XPath expression Customer/name.
>
> > Then someone changes "public string name" to "public string CustName".
> > Project still compiles and there is no schema validation errors (I
> > perform xsd checks before transformation), as xsd is generated form
> > the code. But customer name is not shown on the printout.
>
> I don't think there is an easy way with XSLT/XPath 1.0. You would need
> to implement your own checks or implement your own solution that ensures
> =A0 your XSLT has the correct element and attribute names matching the
> definitions in your schema.
>
> If you move to schema aware XSLT 2.0 as implemented by Saxon 9
> (http://www.saxonica.com/) then you might get assistance from the XSLT
> processor warning you that certain expressions will never find nodes
> with a certain input schema present.
>
> --
>
> =A0 =A0 =A0 =A0 Martin Honnen --- MVP XML
> =A0 =A0 =A0 =A0http://msmvps.com/blogs/martin_honnen/

0
Marcin
12/16/2009 11:10:43 AM
Marcin Ochocki wrote:

> I downloaded saxonhe9-2-0-3n.zip, changed <xsl:stylesheet
> version="1.0" to <xsl:stylesheet version="2.0" in my xslt file and ran
> bin\Transform.exe tool.
> But the result for the changed XPath expression (I renamed a field -
> so it does not exist in xml) is the same - xslt  engine just renders
> empty field.
> 
> So does XSLT2.0 (Saxon?) really can validate misspelled XPath
> expressions? Is it possible?

For schema aware processing you need Saxon-PE or Saxon-EE I think. And 
then you need to use more steps than simply changing the version 
attribute, you need to import any schema you want to validate against.
I am not familiar with the details of using Saxon for schema aware 
processing, you will need to read the documentation (e.g. 
http://www.saxonica.com/documentation/sourcedocs/validation.html) and if 
you have any questions specific to Saxon then I think it is best you 
raise them on the Saxon help mailing list 
http://lists.sourceforge.net/lists/listinfo/saxon-help.


-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
Martin
12/16/2009 12:23:15 PM
On 16 Gru, 13:23, Martin Honnen <mahotr...@yahoo.de> wrote:
> Marcin Ochocki wrote:
> > I downloaded saxonhe9-2-0-3n.zip, changed <xsl:stylesheet
> > version=3D"1.0" to <xsl:stylesheet version=3D"2.0" in my xslt file and =
ran
> > bin\Transform.exe tool.
> > But the result for the changed XPath expression (I renamed a field -
> > so it does not exist in xml) is the same - xslt =A0engine just renders
> > empty field.
>
> > So does XSLT2.0 (Saxon?) really can validate misspelled XPath
> > expressions? Is it possible?
>
> For schema aware processing you need Saxon-PE or Saxon-EE I think. And
> then you need to use more steps than simply changing the version
> attribute, you need to import any schema you want to validate against.
> I am not familiar with the details of using Saxon for schema aware
> processing, you will need to read the documentation (e.g.http://www.saxon=
ica.com/documentation/sourcedocs/validation.html) and if
> you have any questions specific to Saxon then I think it is best you
> raise them on the Saxon help mailing listhttp://lists.sourceforge.net/lis=
ts/listinfo/saxon-help.
>
> --
>
> =A0 =A0 =A0 =A0 Martin Honnen --- MVP XML
> =A0 =A0 =A0 =A0http://msmvps.com/blogs/martin_honnen/

Thank you for your help.

M.
0
Marcin
12/16/2009 1:10:01 PM
Reply:

Similar Artilces:

Outlook Express #60
I don't even know if this is the correct newsgroup to post, but I can't find any group under the name Outlook Express, so I'm trying my luck here. I'm due to upgrade to a new computer, and I'm wondering if I have to save my old mails into diskette or CD. I certainly don't want to lose all my old mails collected in Outlook Express. The big problem is - I'm not able to find anything in Outlook Express that looks like the data files for my old mails. So what do people do when they want to keep their old mails in the course of changing their computer? "p...

How do you format a document in both portait and landscape?
How do you format a document in both portait and landscape? See http://www.word.mvps.org/FAQs/Formatting/LandscapeSection.htm Hope this helps DeanH "Debbie" wrote: > How do you format a document in both portait and landscape? Click on Page Layout tab on the top ribbon, then open page setup, you'll see "portrait" v. "landscape" orientations, then choose one. I would choose the same orientation when printing, in the printing dialogue boxes. However, do you need to load the paper sideways if choosing landscape? I dunt think so. Load it ...

Import outlook.pst from Win2K to outlook express 6 on XP Pro
I have had my Win2000 machine with older version of Outlook Express crash. I have a backup of the outlook.pst file. How do I get Outlook Express 6 on WinXP pro to read this file ? Any help appreciated. The "Import" from outlook 4 does not work. iinet <fobz@iinet.net.nospam.au> wrote: > I have had my Win2000 machine with older version of Outlook Express > crash. > > I have a backup of the outlook.pst file. Outlook Express doesn't use PSTs. > How do I get Outlook Express 6 on WinXP pro to read this file ? You don't. Outlook Express can't o...

How do I remove page numbers in a document sent to me
How do I remove page numbers in a document sent to me? Which version of Word? If you are using Word 2007, just double-click the page number in the header or footer. Select the number and press the Delete key. If there are multiple sections, you may have to delete numbers in other sections separately (if headers/footers have been unlinked). -- Stefan Blom Microsoft Word MVP (Message posted via msnews.microsoft.com) "jackie miles" <jackie miles@discussions.microsoft.com> wrote in message news:DF9C1778-947A-4C9E-8839-A4BA6FD6C27D@microsoft.com... > How ...

Wrapping text in main document around text box in header
When someone creates a text box in a header that extends into the main document but does not extend to the bottom of the page, can text in the main document wrap around that text box in the header, even when it is of varying length? I hope that makes sense and I appreciate any assistance. -- I Teach This is in Word 2007. -- I Teach "I Teach" wrote: > When someone creates a text box in a header that extends into the main > document but does not extend to the bottom of the page, can text in the main > document wrap around that text box in the heade...

outlook express: can not send or receive emails
I can no longer send and receive emails using my outlook express. It just stopped working. I have double checked all the settings, they are correct, I have internet access. And have even established a new email account using outlook. It seems like I might have received a virus that disabled my outlook express. The following message is the only piece of evidence I can find may point to the problem. An unknown error has occurred. Protocol: POP3, Port: 0, Secure(SSL): No, Error Number: 0x800C013B Any suggestions? YOu can email me at davidk65@wayne.edu or contactdavidnow@hotmail....

how to embed a control in XML Document
Hi, I need to add controls like Textbox,Label,Listbox etc dynamically in a WordML document. To be more precise, suppose i have doc and docnodes as two xml nodes, document should be displayed as <doc> <docnodes> Label1 : Textbox1 Label2 : Textbox2 </docnodes> </doc> Can someone help me with this. jayrm100@yahoo.com wrote: > I need to add controls like Textbox,Label,Listbox etc dynamically in > a WordML document. > > > To be more precise, suppose i have doc and docnodes as two xml nodes, > document should be displayed as ...

add a word document as an appendix to an existing word document
Can anyone help me please? I have a finished document and I want to add another document with different formatting as an appendix in Word 2007..... If you have been using different styles for the text in the appendix document (so that there are no style conflicts), it would be as easy as a copy and paste operation. -- Stefan Blom Microsoft Word MVP "Robbie" <Robbie@discussions.microsoft.com> wrote in message news:F565049E-3646-4063-B184-6927EDE1B003@microsoft.com... > Can anyone help me please? > > I have a finished document and I want to a...

Printing Word and excel documents via excel vba
I have a document that has some Excel and some word content i would like to use excel vba to print both a page from word and then a page from excel. I know how to select and open the word document, however i cant find any code to print page X from word. basically i need to: print page 1 of c:\xx\document1.doc print page1 of sheet1 of c:\yy\excelwkbk1.xls print page 2 of c:\xx\document1.doc print page2 of sheet1 of c:\yy\excelwkbk1.xls and so on it will require moving between word and excel - the excel bit i get, but getting back to excel from word, and printing out in word is slightly more...

O.T. FYI BlackBerry Enterprise Server Express for Free for SBS2008
BlackBerry Enterprise Server Express for Free http://na.blackberry.com/eng/services/business/server/express/ Connect two people via BlackBerry� Smartphone's and ideas get bigger. Progress happens faster. Answers get smarter. So imagine what happens when you give a business the freedom to connect all its employees. BlackBerry� Enterprise Server Express enables businesses of any size to quickly and easily get started with the BlackBerry solution. It provides advanced BlackBerry Smartphone features with no additional software or user license fees, and works with any Internet-...

Outlook Express #189
I often receive multiple copies (2 to 4) of the exact same e-mail messages including the exact same time stamp and this , beyond being a nuisance sometimes overlods server memory causing me to lose messages. My ISP (rogers) says it is a microsoft problem, not theirs. Can anyone help? TOMRUS ...

changing a name in mulit parts of a document
I am setting up a word document. This will be used as a template In this document I wish to insert the same "name" throughtout this document. Is it possible to change the name in one spot and all of the others change automatically thanks See http://gregmaxey.mvps.org/Repeating_Data.htm -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>...

how do you place a spreadsheet(s) inside another spreadsheet
I am trying to setup a workbook with spreadsheets that contain other spreadsheets. Does excel allow this? if yes, how can I do it. Hi not 100% sure what you're after here ... a workbook can contain multiple worksheets. Each worksheet contains a grid of cells 256 columns wide & 65536 rows deep. This basic structure of excel can not be altered. Please post back with additional details on what you're trying to achieve and we might be able to suggest a solution. Cheers JulieD "ucastores" <ucastores@discussions.microsoft.com> wrote in message news:DDE44C32-...

Outlook Express asks to enable cookies
I tried to configure Outlook Express to a Hotmail account but it asks that cookies be enabled. Cookie setting on Explorer ias set Low. Also unable to access Hotmail through web page or MSN. Does anyone have an idea where the problem might be? Steve wrote: > I tried to configure Outlook Express to a Hotmail account > but it asks that cookies be enabled. Cookie setting on > Explorer ias set Low. > > Also unable to access Hotmail through web page or MSN. > > Does anyone have an idea where the problem might be? Hotmail access via anything but the Hotmail webpage is bei...

page set up in document
We have different brands of printers - some with affixed trays, others without. In our associated template we have page set up as: (different) first page - tray 1 and other pages - tray 2. This has been made the default setting on that particular template. PROBLEM: When we print first to a plain printer (even the same brand and tray set up), once the document has printed, it reverts to "automatically select" and the tray 1/tray 2 set up has to be done all over again. This template was worked on by our software support (they would have different printers from us). Co...

Help with VBA for document formatting.
Dear all: I am currently working on a rather large document that I need to format a certain specific way. The document includes nearly 57,000 lines of plain text that need to be indented according to a simple rule so that it can then be imported into an application as a tab- delimited file. A member from another forum suggested this might be more easily done with Word instead of Excel so I decided to post this questions here. My system is a Mac G5 running the latest version of Leopard (not Snow Leopard) which is 10.5.8 and I have Microsoft Office 2004 installed (haven't upg...

Import XML into Word Document
Hello, today I read an Article on MSDN on how to create Word templates that use XML schemas. The Articel is called "Creating and Applying an XML Resume Template in Microsoft Office Word 2003" (http://msdn.microsoft.com/office/understanding/xmloffice/codesamples/default.aspx?pull=/library/en-us/odc_wd2003_ta/html/odc_wdxmlresumetemp.asp) The features described are very nice, at least the option to export the data as XML. Now I am searching for a way to import this data into my template. Is there a way to do this? I understand that the saved XML can be used in other applications...

Outlook Express "unable to send receipt"
Helping someone out with a problem using Outlook Express user clicks on some unread messages and then receives "unable to send receipt" error . Checked options and it states the user is not using receipts. Problem occurs randomly and not all messages received give the error when viewed. Any suggestions would be appreciated. Mitchell Juergens Suggestion - post in an Outlook Express group - this group supports Outlook from Microsoft Office. Outlook Express is a part of Internet Explorer. You can also try this site for assistance: http://insideoe.tomsterdam.com --� Milly Sta...

Outlook express #305
I have a computer system on a p2p networking which cannot open Outlook Express. I have tried reinstalling Windows XP pro using the "R" repair function without success. The message I get is as follows. "Outlook Express could not be started, The application was unable to open the Outlook Express message store. Your computer may be out of memory or you disk is full. Contact Microsoft support for further assistance. (0X800C012E, 5)" When I press enter I get a second message. "Outlook Express could not be started because MSOE.dll could not be initialized. Out...

How do I create a bookfold document in Word 2007?
I am new to Word 2007. How do I create a document in booklet form? Thanks I'm sure you'll get better answers in an MSWord forum. dadolim wrote: > > I am new to Word 2007. How do I create a document in booklet form? Thanks -- Dave Peterson ...

How do I print a Publisher document without the margin edge?
I'm working on a Publisher document that has a border around the edges. I would like to print the document so that the border goes all the way to the edge of the paper but I get a 1/4" white margin on the page even though I have set the margins to 0" and the print preview does not show the margin. This is a limitation of your printer, not Publisher. If your printer cannot print full bleed, there's nothing you can do. -- JoAnn Paules MVP Microsoft [Publisher] "Greer" <Greer@discussions.microsoft.com> wrote in message news:1378F597-0DBA-4956-A5F1...

auto numbering spread throughout a document
I have word 2007. I'm working on a process memo with numbered steps. The steps are auto numbered. Within this document also have a series of internal controls that are numbered: "internal control 1.", "internal control 2." etc. Is there a way for me to auto number "internal control" so that each time I have to add one to my document it's automatically number and if I remove one it renumbers? These internal controls appear throughout the document and do have a specific formatting. Does this make sense? Thanks Create a Style for ...

Outlook Express -Unable to delete messages
I have one user who cannot delete messages (from Inbox or Sent Items etc..) using Outlook Express. If I connect to their mailbox using Outlook 2000 on my pc I can delete messages. No configurations have changed. Other staff at their office have no problems. Any ideas? This newsgroup is for support of Outlook 97-2003 from the Office family for Windows PCs. For Outlook Express (OE) support try posting in one of these newsgroups: microsoft.public.inetexplorer.ie4.outlookexpress for OE 4.x microsoft.public.windows.inetexplorer.ie5.outlookexpress for OE 5.x http://support.microsoft.com/newsg...

Global Creation of Word Documents
Is there any way to take a list of items, say 200 words, and globally create 200 word documents, each document containing one item from that list? -- DD Have you tried using mail merge? -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "drdom" <drdom@discussions.microsoft.com> wrote in message news:CB1380EE-87B8-4BDB-AE4E-6D95A58B7011@microsoft.com... > Is there any way to take a list of items, say 200 words, and globally > create > 200 word documents, each document containing one item ...

Sql Server express 2005 trying to install BIDS
I downloaded the only setup program for the Toolkit for sql server express 2005 and am trying to install just BIDS which I do not have on my system but I'm getting an error that says it is already there and the details say: Name: Microsoft SQL Server 2005 Tools Reason: Your upgrade is blocked. For more information about upgrade support, see the "Version and Edition Upgrades" and "Hardware and Software Requirements" topics in SQL Server 2005 Setup Help or SQL Server 2005 Books Online. Build version check: Your upgrade is blocked because the existing com...