Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 17th, 2005, 10:23 AM
Authorized User
 
Join Date: Sep 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default XPath Case Insensitive

Hi,
i am using XPath to parse a file
I am using this imports

import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;

And this is how i parse a XPath Expression

XPath xpath = XPathFactory.newInstance().newXPath();
String expr = "Vendor/text()";
String brand = xpath.evaluate(expr,rdf);
(Where rdf is a node)

But i realize that using the expr stated above, or
String expr = "vendor/text()"; (notice that vendor starts with a lower case v)
is not the same thing

Is there anyway i can tell the XPath evaluator to disregard the case of the expression?

Thank you

 
Old October 17th, 2005, 11:27 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

No. XML is case-sensitive.

Well, if you really have to, you can do

*[lower-case(name()) = 'vendor']/text()

in XPath 2.0.

But there's something badly wrong with your XML document design if you have this requirement.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 17th, 2005, 12:03 PM
Authorized User
 
Join Date: Sep 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks
The XML Document Design i am using is not mine, it's a standard for Mobile Phones, know as UAPROF, but i've noticed that some (very few) don't follow the correct Case, so i'm pretty much tied up here, because each vendor does what they want
But thanks for your anwser

 
Old October 17th, 2005, 12:32 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you have to handle dirty XML (XML that doesn't conform to its specification) then the best way to do it is to write a separate transformation that cleans it up before doing any further processing. Don't let the dirty XML get near your applications, and don't try to make your applications handle dirty XML as well as clean XML.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Case help michael.boucher SQL Server 2005 0 May 23rd, 2008 01:45 AM
Case Insensitive Comparison in Oracle 9i ashu_from_india Oracle 0 December 29th, 2005 02:53 AM
ADO Filter: Case Insensitive moshepack All Other Wrox Books 0 April 29th, 2004 08:51 AM
search string either Upper case or lower case rylemer Beginning VB 6 3 March 24th, 2004 04:23 PM
Check Case in a Case-Insensitive DB nbryson SQL Language 1 January 23rd, 2004 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.