473,795 Members | 2,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to specify namespace in saxon api ??

Greetings, After 6 hours of fruitless research, I ask for your help !

I have an svg file and use Saxon latest implementation, openSource version.

it holds nodes whose path are :
svg/g[@id='textes_x00 20_et_x0020_puc es']/g/text

each text node possess a transform attribute that I want to work with.

The problem is that whatever xPath expression I use, I never fetch any
nodes. According to the samples, it works with regular xml but doesn't
with svg (which is xml !). But well, it just doesn't :(
I tried to get svg width attributes as well but nope

After a lot of research it happenedn that sxon does not know about the
svg namespace. How can I tell him to be aware of it ??
Any ideas ?
The code :

import net.sf.saxon.xp ath.XPathEvalua tor;
import net.sf.saxon.xp ath.XPathExpres sion;
import net.sf.saxon.xp ath.StandaloneC ontext;
import net.sf.saxon.om .NodeInfo;
import net.sf.saxon.xp ath.Variable;
import org.xml.sax.Inp utSource;
import javax.xml.trans form.sax.SAXSou rce;

import java.util.List;
import java.util.Itera tor;

public void go(String filename) throws Exception {

// Create an XPathEvaluator and set the source document

InputSource is = new InputSource(fil ename);
SAXSource ss = new SAXSource(is);
XPathEvaluator xpe = new XPathEvaluator( ss);

StandaloneConte xt sc = (StandaloneCont ext) xpe.getStaticCo ntext();
String expression = "//LINE[contains(., $word)]";

Variable wordVar = sc.declareVaria ble("word", "");
// Set the value of the XPath variable
wordVar.setValu e("svg");
//expression = "//g[@id='textes_x00 20_et_x0020_puc es']/g/text";
// Compile the XPath expressions used by the application
XPathExpression findLine = xpe
.createExpressi on(expression);

// Find the lines containing the requested word
List matchedLines = findLine.evalua te();

// Process these lines
for (Iterator iter = matchedLines.it erator(); iter.hasNext(); ) {

// Get the next matching line
NodeInfo line = (NodeInfo) iter.next();

// // Find where it appears in the play
// findLocation.se tContextNode(li ne);
// System.out.prin tln("\n" +
findLocation.ev aluateSingle()) ;
//
// // Find out who the speaker of
this line is
// findSpeaker.set ContextNode(lin e);

// Output the name of the speaker and the content of the
// line
// System.out.prin tln(findSpeaker .evaluateSingle () + ": "
// + line.getStringV alue());
// Finish when the user enters "."

}
System.out.prin tln("Finished." );

}
Jul 20 '05 #1
0 1911

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

Similar topics

20
6799
by: Bernd Fuhrmann | last post by:
Hi! I have some trouble with some simple stupid XSLT-stuff. My stylesheet: ------------- <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
1
3084
by: Collin VanDyck | last post by:
I've got a simple Java program: public class Test { public static void main(String args) { System.out.println("xalan class: " + org.apache.xalan.processor.TransformerFactoryImpl.newInstance().getClass().g etName()); System.out.println("saxon class: " +
4
2418
by: Johannes Busse | last post by:
Hello NG, I'm struggling with the following problem. I think can be solved quite easily (in fact it should be a FAQ), but it seems that I cannot solve it myself :-( my source looks like this: <?xml version="1.0" encoding="utf-8"?>
4
3965
by: mikea_59 | last post by:
I'm getting different results from XMLSpy and Saxon translations - both are updated versions. Maybe someone here can give me some insight. Here is my input: <MESSAGE> <msgName> <B enum="1"> <C>"1234"</C> </B>
2
2111
by: Dr. Roger Wießner | last post by:
Hello! I am a newbie to XSLT and need a freeware/GNU Tool to get experience with this new topic. Which one is a good XSLT? Xalan or Saxon, or which one else? Thank you a lot!
4
2125
by: Rolf Kemper | last post by:
Hi All, ned help on the example below. It works fine for msxml3/4 but has problems with saxon. Saxon complains "can not find matching function ..... " My target is to write style sheets usable for msxml3 , msxml4 , saxon .. Is there a general solution ?
1
2668
by: Swami Tota Ram Shankar | last post by:
"Bob Weigel" <dontuwish@nothing.net> wrote in message > > While George Bush, is the epitome of evil, racism, and uncompassionate > > conservatism, Kerry is either deluded, very deluded, or plainly a liar. > As to bush being racist...sorry I dont' see that. You make nasty > presumptions about others which makes you no fun to read... uncompassionate > conservativism...I'd like to take you on a trip where we help people. I'd > give...
2
2308
by: klaus | last post by:
Hello, I want to pass a parameter to an xslt using saxon on a windoes 2000 system. I'm using this command line in a batch file: java -jar c:\programme\saxon\saxon8.jar -v -novw -o ...\html_files\output.html ..\xml_files\input.xml ...\xslt\xml2html.xsl language=EN
5
3416
by: jhurrell | last post by:
I have been having some trouble getting my XSL style sheet to parse correctly. I have some XML outputted from an SQL-Server, that I then need to turn into multiple HTML files. This I have done with moderate success using Saxon and <xsl:result-document>, but Saxon is throwing an error and I don't know how to resolve it. Maybe someone can offer some advice? This is a long question, for which I apologise... OS= Windows XP Pro, Saxon=8.8 XML...
0
9673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9044
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7543
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.