Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » xml namespace parsing
xml namespace parsing [message #13380] Fri, 27 April 2007 18:16 Go to next message
Eclipse User
Originally posted by: ymo.noemail.com

Hi.

I am trying to parse an xml file and it looks like the Xpath is not
supported fully. Can you specify is you can have :


model file:
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:ui="http://www.sun.com/web/ui">
<jsp:directive.page contentType="text/html;charset=UTF-8"
pageEncoding="UTF-8"/>
<f:view>
<ui:page binding="#{Page1.page1}" id="page1">
<ui:html binding="#{Page1.html1}" id="html1">
<ui:head binding="#{Page1.head1}" id="head1">
<ui:link binding="#{Page1.link1}" id="link1"
url="/resources/stylesheet.css"/>
</ui:head>
<ui:body binding="#{Page1.body1}" id="body1"
style="-rave-layout: grid">
<ui:form binding="#{Page1.form1}" id="form1"/>
</ui:body>
</ui:html>
</ui:page>
</f:view>
</jsp:root>

template
<c:iterate select="/jsp:root/f:view/ui:page" var="curPage" >
<ws:file template="src-jet/dump.jet"
path="{$org.eclipse.jet.resource.project.name}/src-gen/test.txt " />
</c:iterate>

I am now getting :
Error: No namespace URI found for prefix "jsp"

I saw some workarounds on this issue on the newsgroups. I was thinking
this maybe a jet1 issue and the namespace has been better supported by now.

i have now :
eclipse 3.2.2
emft 0.7.2
Re: xml namespace parsing [message #13414 is a reply to message #13380] Mon, 30 April 2007 12:46 Go to previous message
Paul Elder is currently offline Paul Elder
Messages: 849
Registered: July 2009
Senior Member
Hi:

You are correctly, the XPath implementation is not complete. In particular,
there is no mechanism exposed for associating namespace URIs to prefixes.
There are, however some alternatives:

1) If the namespaces jsp, f and ui do not have element names that conflict,
you can simply write your XPath expression like this:

/root/view/page

2) If you absolutely need to select against namespaces, I suggest you do the
following:

a) define XPath variables for the namepace URI's:

<%-- only need to do these one, in main.jet --%>
<c:setVariable var='f' select=" 'http://java.sun.com/jsf/core' "/>
<c:setVariable var='h' select=" 'http://java.sun.com/jsf/html' "/>
<c:setVariable var='jsp' select=" 'http://java.sun.com/JSP/Page' "/>
<c:setVariable var='ui' select=" 'http://java.sun.com/web/ui' "/>

b) Write you Xpath expressions like this:

/root[$jsp = namespace-uri()]/view[$f = namespace-uri()]/page[$ui =
namespace-uri()]

Finally, I have created bug 184692
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=184692 ), which suggests
exposing a method of defining namespace prefixes for tag XPath expressions.

Paul
Previous Topic:Freshly Created JET2 Transformation Failure
Next Topic:passing parameters
Goto Forum:
  


Current Time: Tue Sep 02 23:46:43 GMT 2014

Powered by FUDForum. Page generated in 0.09254 seconds