XSL matches in RSA/eclipse, not with Xalan 2.5.1

P

pgreaves

hi there

i have developed a style sheet that works fine in the XML perspective
of Rational Software architect, but when i add it to my application, it
appears to match no nodes.

my XSL that matches nodes looks like this:

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:xalan="http://xml.apache.org/xslt"
xmlns:crm="http://w3.ibm.com/xmlns/ibmww/crm"
xmlns:ci="http://w3.ibm.com/xmlns/ibmww/ci"
xmlns:foo="http://w3.ibm.com/xmlns/ibmww/com"
exclude-result-prefixes="foo ci crm xalan">

<xsl:eek:utput method="xml" indent="yes"/>
<xsl:template match="/">
<locations>
<xsl:apply-templates select="//foo:Geography" />
</locations>
</xsl:template>

<xsl:template match="foo:Geography">


<xsl:for-each select="descendant:: //blah blah

and we're fine from there : i get a lot of <location> child elements of
my parent <locations> element, so the select="//foo:Geography" and the
match are working ok. but then i run it inside my java app which has
specific libs from xalan/xerces ( the DOM is the input XML instance and
that is fine, and the stylesheet is correctly located):

private String getLocations(Document source) throws Exception{

Writer writer = new StringWriter();
InputStream styleSheet =
this.getClass().getResourceAsStream("/locations.xsl");

TransformerFactory transFactory = TransformerFactory.newInstance();
Templates template =
transFactory.newTemplates(new StreamSource(styleSheet));

Transformer transformer = template.newTransformer();

DOMSource domSource = new DOMSource(source);

transformer.transform(
domSource,
new javax.xml.transform.stream.StreamResult(writer));
String result = writer.toString();
return result;
}

i get an empty instance : basically like this:

<locations />

i am wondering if its a namespaces issue? it seems to me that


<xsl:apply-templates select="//foo:Geography" />

is matching no nodes in the application, but plenty in the IDE. can
anyone help here? do i need to inform the API classes more
specifically about the namespace?

regs and tia,

peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top