You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "dcaveney (JIRA)" <xa...@xml.apache.org> on 2005/01/18 07:19:17 UTC
[jira] Updated: (XALANJ-1801) Can't access attributes by name from a nodeset()
[ http://issues.apache.org/jira/browse/XALANJ-1801?page=history ]
dcaveney updated XALANJ-1801:
-----------------------------
Attachment: NodesetElementByName.txt
Yes, I was compiling with 2.6.0 but running the app with another version. Everything works much better now except that I still can't access an element in a nodelist by its element name. The attached stylesheet gives the following result:
Number of elements: [2]
Number of books: [0]
> Can't access attributes by name from a nodeset()
> ------------------------------------------------
>
> Key: XALANJ-1801
> URL: http://issues.apache.org/jira/browse/XALANJ-1801
> Project: XalanJ2
> Type: Bug
> Components: transformation, Xalan-interpretive
> Versions: CurrentCVS
> Environment: Operating System: Windows XP
> Platform: PC
> Reporter: dcaveney
> Assignee: Xalan Developers Mailing List
> Attachments: NodesetElementByName.txt, nodelist_result.txt, nodelist_test.txt
>
> Attributes in elements retrieved using the xalan:nodelist() function can't be
> retrieved by name:
> <value-of select="xalan:nodeset($books)/*[1]/@*[1]"/> is OK
> but,
> <value-of select="xalan:nodeset($books)/*[1]/@author"/> returns nothing.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org
Re: AW: How to use setStylesheetParam method with XalanElement pointer
Posted by Jarek Lubczyński <el...@elkomtech.com.pl>.
On 21 Jan 2005 at 10:35, Tobias Schütte wrote:
>
> Hi jarek,
>
> create a bug report (improvement request),
> then I will take a look at it and post some patches that hopefully
> find its way to the source tree *wink*
>
> tobias
Hi, Tobias
Well, I have applied changes which you've described in
http://issues.apache.org/jira/browse/XALANC-451
and it works excellent. Thanks a lot.
--
Pozdrawiam
Jarek LubczyÄski
There are 10 kinds of people:
Those who understand binary and those who don't
AW: How to use setStylesheetParam method with XalanElement pointer
Posted by Tobias Schütte <ts...@edvwl.de>.
Hi jarek,
create a bug report (improvement request),
then I will take a look at it and post some patches that hopefully find
its way to the source tree *wink*
tobias
> On 20 Jan 2005 at 23:36, david_n_bertoni@us.ibm.com wrote:
> [...]The current code only
> allows top-level params to be XPath expressions that are evaluated in
> the context of the source document. This is clearly an omission,
> which we can correct in the next release.
So I will be looking at Xalan 'whats new' info patiently :-)
>
> A hackish way to do is to:
[...]
Thanks a lot Dave, I will try your method.
--
Pozdrawiam
Jarek LubczyÄski
There are 10 kinds of people:
Those who understand binary and those who don't
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org
Re: How to use setStylesheetParam method with XalanElement pointer
Posted by Jarek Lubczyński <el...@elkomtech.com.pl>.
On 20 Jan 2005 at 23:36, david_n_bertoni@us.ibm.com wrote:
> [...]The current code only
> allows top-level params to be XPath expressions that are evaluated in
> the context of the source document. This is clearly an omission,
> which we can correct in the next release.
So I will be looking at Xalan 'whats new' info patiently :-)
>
> A hackish way to do is to:
[...]
Thanks a lot Dave, I will try your method.
--
Pozdrawiam
Jarek LubczyÄski
There are 10 kinds of people:
Those who understand binary and those who don't
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org
RE: How to use setStylesheetParam method with XalanElement pointer
Posted by Jarek Lubczyński <el...@elkomtech.com.pl>.
On 20 Jan 2005 at 14:04, Tobias Schütte wrote:
>
> hi jarek,
Hi, Tobias
Thank you for response
> as you described earlier, XSLTEngineImpl has a method for passing
> name/xobjectptr pairs as top level arguments. The problem is that the
> corresponding XalanTransformer method is missing. you only have to add
> this method to the XalanTransformer and some additional code to store
> the name/xobjectptr pairs (similar to the name/xpath pairs).
Well, as a matter of fact I had done this before I wrote my letter to the xalan-dev mailing list.
And it doesn't work. Maybe I did something wrong with converting XalanElement* to XObjectPtr
- examples attached do Xalan are not quite clear to me with this matter. I have found helpful
parts of given modules:
...\samples\SimpleXPathAPI\SimpleXPathAPI.cpp
...\samples\XPathWrapper\XPathWrapper.cpp
...\src\xalanc\XPath\XPathEvaluator.hpp
My conversion code is given below (I've cut some lines like XALAN_USING_XALAN directives):
XPathEvaluator theEvaluator;
XalanNode* theSourceNode = ... // has got as a parameter
const char* theSourcePath = "."; // I need whole node to be passed as top level param
bool theResult = false;
try
{
// We'll use these to parse the XML file.
XalanSourceTreeDOMSupport theDOMSupport;
// is this neccesary here? {
XalanSourceTreeParserLiaison theLiaison( theDOMSupport);
// Hook the two together...
theDOMSupport.setParserLiaison( &theLiaison);
// was this neccesary here? }
const XObjectPtr theXObject
(
theEvaluator.evaluate // ???? is this the right method???
(
theDOMSupport,
theSourceNode,
XalanDOMString( theSourcePath).c_str()
)
);
/* now I can use theXObject as shtylesheet param, can't I ??? */
}
catch( ...)
{
}
Nevertheless I will try to make my code working next week. If I fail I'd like to ask for further
assistance.
PS. I can send the XalanTransformer.* source with my changes if Xalan developers find it
useful in future versions of XALAN. I can make the full test / example source code as well (of
course as soon as the code is going to work ;-) ).
>
> tobias
--
greetings
Jarek Lubczynski
There are 10 kinds of people:
Those who understand binary and those who don't
Re: How to use setStylesheetParam method with XalanElement pointer
Posted by da...@us.ibm.com.
> First of all I'd like to say I've sent similar question to xalan-user
> mailing list and nobody replied with answer which would be
satisfactional
> for me, so I am resending the question to this mailing list. Sorry for
> disturbance if it is not the proper list I should use.
Well, the reason you didn't get a "satisfactory" answer is because there's
no real "satisfactory" way to do it. The current code only allows
top-level params to be XPath expressions that are evaluated in the context
of the source document. This is clearly an omission, which we can correct
in the next release.
A hackish way to do is to:
1. Create an extension function that accepts a string, and returns a
node-set containing the XalanNode instance you're interested, based on the
value of the string. The function will need a way to lookup the data
given the string, so you'll need to give it a reference or pointer to a
data structure it can use.
2. Install your extension function into the processor.
3. Add a top level variable with a select attribute that calls the
extension function, using the string from the top-level param.
You can then use the top-level variable as a node-set.
Take a look at the ExternalFunction sample for information about writing
and installing an extension function.
The stylesheet when then look something like this:
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:MyENS="http://www.foo.com/my.extension.namespace"
extension-element-prefixes="MyENS" >
<xsl:param name="node-key" select="''" />
<xsl:variable name="node-set-param" select="MyENS:getNode($node-key)" />
...
</xsl:stylesheet>
This assume you've called your function "getNode", and installed it in the
namespace "http://www.foo.com/my.extension.namespace". Of course, you are
free to call it whatever you like, as long as the namespace doesn't
conflict with any other namespace in the stylesheet or in the installed
extension functions.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org
RE: How to use setStylesheetParam method with XalanElement pointer
Posted by Tobias Schütte <ts...@edvwl.de>.
hi jarek,
as you described earlier, XSLTEngineImpl has a method for passing
name/xobjectptr pairs as top level arguments. The problem is that the
corresponding XalanTransformer method is missing.
you only have to add this method to the XalanTransformer and some
additional code to store the name/xobjectptr pairs (similar to the
name/xpath pairs).
tobias
-----Ursprüngliche Nachricht-----
Von: Jarek Lubczyñski [mailto:eljot@elkomtech.com.pl]
Gesendet: Dienstag, 18. Januar 2005 10:08
An: xalan-dev@xml.apache.org
Betreff: How to use setStylesheetParam method with XalanElement pointer
Hi everybody.
First of all I'd like to say I've sent similar question to xalan-user
mailing list and nobody replied with answer which would be
satisfactional for me, so I am resending the question to this mailing
list. Sorry for disturbance if it is not the proper list I should use.
I am writning an application (in c++) with xslt capabilities and I
decided to use Xalan-C as a transformer. And now I have got a problem
with setting a number of parameters to stylesheet when parameter list is
given as XalanElement* (or similar) pointer.
There is a simple way to do this in Java. Class
javax.xml.transform.Transformer
has a method
setParameter( String name, Object value)
So I can write (in java)
import javax.xml.transform.*
import org.w3c.dom.*
class MyClass
{
public void mySetParameter( String name, Transformer transformer,
Element element)
{
transformer.setParameter( name, element);
}
};
And my problem is how to do it using Xalan C++. I _must_ do it in the
same (or similar) way as in java solution described above because of the
following:
1. A number of parameters is known only when performing the
transformation
2. I can have the parameter list _only_ as a XalanElement* or similar
pointer.
I've found class XalanTransformer
(xalanc/XalanTransformer/XalanTransformer.hpp) has got only two
instances of method setStylesheetParam - first using const char*, and
second one using XalanDOMString& as parameters. And that's all. But
there is XSLTEngineImpl object which is used as XSLT processor and it
has a method defined below
void XSLTEngineImpl::setStylesheetParam(
const XalanDOMString& key,
XObjectPtr value);
which prototype seems to look like it could be useful to solve my
problem. But this method is called nowhere in Xalan C++ - neither in
source nor in sample/test modules. So it seems to me the usage of this
method requires XalanTransformer module to be rewritten. Another problem
is how to make XObjectPtr object from XalanElement* pointer.
Now I am training with Xalan 1.9.0, Xerces 2.6.0 and ICU 3.2
Here is sample source document, stylesheet, param list document and
target documents I should have as a result of transformations.
//=== proper stylesheet to resolve parameters =========
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:param name="params" select="/aaa"/>
<xsl:template match="/">
<Res>
<xsl:apply-templates select="//Test"/>
</Res>
</xsl:template>
<xsl:template match="Test">
<xsl:apply-templates select="@*"/>
</xsl:template>
<xsl:template match="@*">
<xsl:variable name="pName" select="name(.)"/>
<xsl:variable name="tmpValue" select="$params/Param[@nm =
$pName]/@vl"/>
<xsl:variable name="pValue">
<xsl:choose>
<xsl:when test="$tmpValue != ''">
<xsl:value-of select="$tmpValue"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<Param nm="{$pName}" vl="{$pValue}"/>
</xsl:template>
</xsl:stylesheet>
//=== sample source document =========================
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Test t1="1" t2="2"/>
</root>
//=== sample document with parameter list =================
<?xml version="1.0" encoding="UTF-8"?>
<Params>
<Param nm="t1" vl="11"/>
<Param nm="t2" vl="22"/>
</Params>
// === expected result document _without_ setting above parameter node
<?xml version="1.0" encoding="UTF-8"?>
<Res>
<Param vl="1" nm="t1"/>
<Param vl="2" nm="t2"/>
</Res>
// === expected result document _with_ setting above parameter node
<?xml version="1.0" encoding="UTF-8"?>
<Res>
<Param vl="11" nm="t1"/>
<Param vl="22" nm="t2"/>
</Res>
//=== end of sample documents ======================
Can anybody help me? Thanks in advance,
--
Greetings
Jarek Lubczynski
There are 10 kinds of people:
Those who understand binary and those who don't
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org
How to use setStylesheetParam method with XalanElement pointer
Posted by Jarek Lubczyński <el...@elkomtech.com.pl>.
Hi everybody.
First of all I'd like to say I've sent similar question to xalan-user mailing list and nobody replied
with answer which would be satisfactional for me, so I am resending the question to this
mailing list. Sorry for disturbance if it is not the proper list I should use.
I am writning an application (in c++) with xslt capabilities and I decided to use Xalan-C as a
transformer. And now I have got a problem with setting a number of parameters to stylesheet
when parameter list is given as XalanElement* (or similar) pointer.
There is a simple way to do this in Java. Class
javax.xml.transform.Transformer
has a method
setParameter( String name, Object value)
So I can write (in java)
import javax.xml.transform.*
import org.w3c.dom.*
class MyClass
{
public void mySetParameter( String name, Transformer transformer, Element element)
{
transformer.setParameter( name, element);
}
};
And my problem is how to do it using Xalan C++. I _must_ do it in the same (or similar) way
as in java solution described above because of the following:
1. A number of parameters is known only when performing the transformation
2. I can have the parameter list _only_ as a XalanElement* or similar pointer.
I've found class XalanTransformer (xalanc/XalanTransformer/XalanTransformer.hpp) has got only
two instances of method setStylesheetParam - first using const char*, and second one using
XalanDOMString& as parameters. And that's all. But there is XSLTEngineImpl object which is
used as XSLT processor and it has a method defined below
void XSLTEngineImpl::setStylesheetParam(
const XalanDOMString& key,
XObjectPtr value);
which prototype seems to look like it could be useful to solve my problem. But this method is
called nowhere in Xalan C++ - neither in source nor in sample/test modules. So it seems to
me the usage of this method requires XalanTransformer module to be rewritten. Another
problem is how to make XObjectPtr object from XalanElement* pointer.
Now I am training with Xalan 1.9.0, Xerces 2.6.0 and ICU 3.2
Here is sample source document, stylesheet, param list document and target documents I
should have as a result of transformations.
//=== proper stylesheet to resolve parameters =========
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:param name="params" select="/aaa"/>
<xsl:template match="/">
<Res>
<xsl:apply-templates select="//Test"/>
</Res>
</xsl:template>
<xsl:template match="Test">
<xsl:apply-templates select="@*"/>
</xsl:template>
<xsl:template match="@*">
<xsl:variable name="pName" select="name(.)"/>
<xsl:variable name="tmpValue" select="$params/Param[@nm = $pName]/@vl"/>
<xsl:variable name="pValue">
<xsl:choose>
<xsl:when test="$tmpValue != ''">
<xsl:value-of select="$tmpValue"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<Param nm="{$pName}" vl="{$pValue}"/>
</xsl:template>
</xsl:stylesheet>
//=== sample source document =========================
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Test t1="1" t2="2"/>
</root>
//=== sample document with parameter list =================
<?xml version="1.0" encoding="UTF-8"?>
<Params>
<Param nm="t1" vl="11"/>
<Param nm="t2" vl="22"/>
</Params>
// === expected result document _without_ setting above parameter node
<?xml version="1.0" encoding="UTF-8"?>
<Res>
<Param vl="1" nm="t1"/>
<Param vl="2" nm="t2"/>
</Res>
// === expected result document _with_ setting above parameter node
<?xml version="1.0" encoding="UTF-8"?>
<Res>
<Param vl="11" nm="t1"/>
<Param vl="22" nm="t2"/>
</Res>
//=== end of sample documents ======================
Can anybody help me? Thanks in advance,
--
Greetings
Jarek Lubczynski
There are 10 kinds of people:
Those who understand binary and those who don't