Xalan: extension element, evaluating xsl:attribute in an extension
Hi,
Can I evaluate in an extension method of an extension class an <xsl:attribute ... ?
for example in:
<test:layout figure="rectangle" >
<xsl:attribute name="color"><xsl:value-of select="$var1" /></xsl:attribute>
</test:layout>
having Test as the extension class, and "layout" the corresponding method, I need to evaluate attribute "color", I have test it and when Test.layout is called it does'nt has color attribute, is there any way to evaluate the <xsl:attribute ... expression to access the value of color ?
thanks for any help.
Hi, I found the answer, and here it is for any body with same dude:
String attrExpr = ((ElemExtensionCall)elem).getAttribute ( "color", context.getContextNode(), context.getTransformer() );
org.apache.xpath.XPathContext xctxt = context.getTransformer().getXPathContext();
XPath myxpath = new XPath(attrExpr, elem, xctxt.getNamespaceContext(), XPath.SELECT);
XObject xobj = myxpath.execute(xctxt, context.getContextNode(), elem);
return xobj.str(); // this is the value of the attribute.
in xslt: <test:entension1 color="@Attr" /> or any other xPath
I found it at Redirect.java
thanks to you all.
Similar Messages
-
Xalan: nesting transformations via extension element
Hi,
I'm doing XSLT transformations using xalan to get HTML, I have an extension element and a java class to do it, the corresponding method of this class, applies another tranformation and wants to return this result to the transformation result tree, I have this situation several times, in fact I have a tree of nested transformations this way to get a finally HTML. Well, here is the problem:
the methods of the class (of the extension) returns a Document, and the result is so strange (at least for me), it does not include any attributes, just the elements: e.g. when xslt says <table width="100%" border="0" height="100%" cellpadding="0" cellspacing="0">, result only says <table>.
Can anyone help me please?
thanks.here is a short of the context:
//sample xslt.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rwfa="xalan://rwfa.client.NSHandler"
extension-element-prefixes="rwfa" >
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<table width="100%" border="0" height="100%" cellpadding="0" cellspacing="0">
<tr height="100%">
<td width="200" bgcolor="#AE0C0C" valign="top" style="width:200;" nowrap="true">
<rwfa:client />
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
//extension class.
public class NSHandler {
public Document client(org.apache.xalan.extensions.XSLProcessorContext context, org.w3c.dom.Element elem) {
// (1) create a new document
Document doc = newDocument();
// parse an xml document
Source xml = getXML();
// creates a new transformer based on an xslt like the above
// but with another (or just without any) element from the rwfa namespace.
Transformer transformer = getTransformer();
// creates a Result descendent based on the document (1)
Result result = new DOMResult( doc );
// set some output properties
transformer.setOutputProperty( OutputKeys.OMIT_XML_DECLARATION, "yes" );
transformer.setOutputProperty( OutputKeys.METHOD, "html" );
transformer.setOutputProperty( OutputKeys.INDENT, "yes" );
transformer.setOutputProperty( OutputKeys.ENCODING, "ISO-8859-1" );
//apply the transformation
transformer.transform(xml, result);
//debuging, here de doc is full, e.g. it has all attributes for every element.
return doc;
//but in the whole result, inner tranformation's elements appear without any attribute,
//only the most external tranformation seems to be full. -
How to implement a Xalan extension element
I need an extension for Xalan to create URLs and anchors, as for example like:
<link>/this/is/some/url.html</link>
or
<link href="/this/is/some/url.html"><img src="/some/image.jpg"/></link>
Since the link extension should support to have further nodes as it's content, I thought it is a good idea to implement an extension element that returns a Node or an Element.
My problem is that I don't know how to create a new Nodeand add it to the stylesheet.
The Xalan objects throw an UnsupportedOperationException when I call createElement on the context or extension call element. Same for importNode when I create a new Node from another document instead.
What I could also do is to write an extension function that returns a string. But then I dont know how to use context.transformToString properly, because I want the sub-elements to be also transformed.
Any suggestions?
DominikHi Dominik,
I'm not 100% sure, but I think the problem is the following:
According to the XSLT processing model the input document shoud be immulable.
So if you write a Java method which has a Node as a parameter you must not manipulate this node.
To do it nonetheless you might create a new Document and call importNode on the new document (Node editableNode = newDoc.importNode(immutableNode);). Then you can edit the new node and return it as you like.
But I'm afraid it is not possible (again due to the processing model) to have your stylesheet to process this newly created elements in the same transformation.
Best Wishes
esprimo
Edited by: esprimo on Sep 1, 2008 6:17 AM -
Xsl:attribute error in oraxsl command line
Hi Forum,
I'm getting error XML-22047 when trying to use xsl:attribute.
Here's the test XML I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<level1>Test-Content</level1>
</root>
now, this is the stylesheet I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mdm="schema.condes.org/mds/meta" version="2.0" xml:space="preserve">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="root">
<Foo>
<xsl:attribute name="test">testing attribute</xsl:attribute>
<xsl:apply-templates/>
</Foo>
</xsl:template>
</xsl:stylesheet>
If I run this, it throws error XML-22047, invalid instantiation of 'attribute' in 'element' context (translated from the German error message...)
Has anybody seen this and could advice me some help?
Thanks, JürgenUse xsl:element instead of explicit element.
<xsl:template match="root">
<xsl:element name="Foo">
<xsl:attribute name="test">testing attribute</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template> -
How can I remove an OVS extension from a context attribute?
In our Web Dynpro application we provide a generic search mask to the user. The information about the search fields like labels, length etc. is retrieved from the backend during runtime. Also, the information if there should be a value help available or not is read from the backend during runtime. In case there should be a value help for a search field we just add an OVS extension, using method WDValueServices.addOVSExtension(...). For this, we pass the AttributeInfo of all relevant context attributes to this method.
The problem is now the following: The user can switch between different kinds of search masks. Because of the generic implementation all use the same Web Dynpro context. So it might be that the search field #1 on the first input mask has a value help whereas search field #2 on the second input mask doesn't. But if we once have added an OVS extension to the context attribute of search field #1 it can apparently never be removed anymore. At least I couldn't find a method to remove it.At least your second proposal would work for sure if I had only static context nodes apart from the dynmic OVS context. But in my case I can not use wdContext.reset(false) since I have dynamic context nodes in my controller that would get lost. And unfortunately, there is no method available to reset a specific context node only instead of the whole context.
I contacted the responsible Web Dynpro developers in the mean time and they offered to implement an API in SP11 to remove the OVS. -
<xsl:attribute name="xdofo:rowspancell-repeat-nextpage" xdofo:ctx="block">true</xsl:attribute>
Hello, can you provide me some example on how to use this code? i tried putting this code in a field in a table however it doesn't do any changes in my report, the header still don't repeat.
i'm aware of the word functionality to repeat a header, but due to the structure of my table, that method will changes the output of my report. the reason is i have a looping condition in that header, so if i tried to repeat it, the looping also repeats.
to summarize my table outline:
<HEADER1>---repeating already
<HEADER2 with looping condition>---> the one that i want to repeat
both headers belongs to a one table
i tried separating the header 2 to another table but it ruins my report output
any methods on how this can be done?
thanks in advance! :)Hi All
Thanks For Your Efforts and replays
could anyone pls raise SR for it ?Because I do not have Privilege to do so -
*<xsl:attribute name="xdofo:rowspancell-repeat-nextpage" xdofo:ctx="block">true</xsl:attribute>*
Hello, can you provide me some example on how to use this code? i tried putting this code in a field in a table however it doesn't do any changes in my report, the header still don't repeat.
i'm aware of the word functionality to repeat a header, but due to the structure of my table, that method will changes the output of my report. the reason is i have a looping condition in that header, so if i tried to repeat it, the looping also repeats.
to summarize my table outline:
<HEADER1>---repeating already
<HEADER2 with looping condition>---> the one that i want to repeat
both headers belongs to a one table
i tried separating the header 2 to another table but it destroys my report output
thanks in advance! :)Hi
You may get help if you post your question on its forum.
XML DB
-Priyanka -
Bug w/ xsl:attribute-set in java xdk
Hi - I found what seems to be a bug in the 9.0.0.2.0.0A xdk beta for java. In xsl, if you have an empty xsl:attribute-set (one that uses other attribute sets but does not define any of it's own), the XSL Processor gives an internal error. Adding an attribute to the set fixes the problem.
Example:
<xsl:attribute-set name="foo" use-attribute-sets="set1 set2"/>
Gives:
(Error) An internal error condition occurred. at oracle/xml/parser/v2/XSLProcessor.reportException (XSLProcessor.java:694) at oracle/xml/parser/v2/XSLProcessor.newXSLStylesheet (XSLProcessor.java:500) at oracle/xml/parser/v2/XSLStylesheet.<init>
Changing it to:
<xsl:attribute-set name="foo" use-attribute-sets="set1 set2">
<xsl:attribute name="bug"/>
</xsl:attribute-set>
Gives:
No error
Is this a bug or are you required to define at least one new attribute in every attribute set?
nullcorrect typos:
I can't reproduce the error you got by defining the following stylesheet. Please let me know if anything I misunderstand.
XSL:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:attribute-set name="set1">
<xsl:attribute name="set1">good</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="set2">
<xsl:attribute name="set2"/>
</xsl:attribute-set>
<xsl:attribute-set name="foo" use-attribute-sets="set1 set2">
</xsl:attribute-set>
<xsl:template match="/">
<out xsl:use-attribute-sets="foo">this is a try</out>
</xsl:template>
</xsl:stylesheet>
RESULT:
<?xml version = '1.0'?>
<out set1="good" set2="">this is a try</out>
null -
Do you support xsl:attribute-set?
I could not get xsl:attribute-set and xsl:use-attribute-sets to work. Do you support them?
regards
tomas y
nullThe following simple test works for me using the 2.0.2.9, 2.0.2.10, and 2.1.0.0 Beta versions of Oracle XSLT processor:<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<test xsl:use-attribute-sets="title-style"/>
</xsl:template>
<xsl:attribute-set name="title-style">
<xsl:attribute name="font-size">12pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:attribute-set>
</xsl:stylesheet>Which produces the output:
<test font-size="12pt" font-weight="bold"/>
as expected when applied to any XML source document.
What particular use is not working for you? -
Xsl attribute font-size doesnt work
Hi,
I wanted to set the font-size dynamically.
I tried as below:
<xsl:attribute xdofo:ctx="incontext" name="font-size">30pt</xsl:attribute>
<?attribute@incontext:font-size;'30pt'?>
nothing worked.
But If I give the same for font-weight it works.
Whereas If I use <fo:block font-size="30pt">TEXT</fo:block> it works as expected.
May I know why xsl attributes doesnt work in this case?
Thanks in Advance.Hi,
If i understand, you want different font-size for different text blocks which contain more than one row?
E.g.
<font size="1">Some text in
first block</font></br>
<font size="2">Some text in
second block</font></br>
<font size="3">Some text in
third block</font></br>
Something like that? -
DropDownByKey UI Element and Model Attribute
Hi
The DropDownByKey UI Element can be linked to value attribute, which are simple types.
Now if i try to link them to model attribute which are simple types pertaining to some model classes, its not happening.
so my question is how to attach any DropDownByKey UI Element with Model attribute which will get data from model to which it is attached?
thanks
SrikantD.V.,
Whether or not DDK (DropDownByKey) works with model attribute depends on type of attribute (actually, type of model class property that stays behind this attribute)
If the type contains enumeration itself then DDK works.
So, you have the following options (dynamically populating values set will not work here):
1. Alter type on back-end to include enumeration
2. Use DDI (DropDownByIndex) as suggested here
3. Create sub-node with cardinality 1..1 (better keep singleton false), then add value attribute with the same basic type (string, int etc) and set it flag calculated to true. WD will generate getter / setter for this attribute -- just return / set original model attribute in this method. Next:
3.a Either create new simple DDIC type for calculated attribute and define enumeration here
3.b Or modify SVS of calculated attribute at run-time as suggested in this thread
Valery Silaev
EPAM Systems
http://www.netweaverteam.com/ -
Element type IntegerValue in a BO Extension
Hi guys,
simple question:
why can not I create an element of "integerValue" in a BO Extension.
Kind Regards,Hi Felipe,
Only a subset of all PSM enabled data types are available to be used in an extension BO. The Repository Explorer does not document this. The easiest way to know what is available is to use the code completion function (ctrl + space) to see what data types are available.
One alternative in this situation is to use the Decimal data type, while setting the number of places after the decimal to zero. Something like this:
[Decimal (x,0)] element MyDecimal : DecimalValue;
Where x is anything up to 29, the total number of digits allowed. Keep in mind that negative values will use one place for the negative sign. This means only 28 actual digits for negative numbers.
Cheers!
Nick -
I am getting an error - An error occurred while installing the extension “Lastpass”. Not just Lastpass, ANY extension I try to install. I just updated to Mavericks 10.9.1. Safari version 7.0.1. This is super frustrating. I was going to try to delete the extentions.plist and I cannot find that. I reset Safari. I tried just sropping files into the extentions folder, that doesn't work. Can someone please help?
Back up all data.
This procedure will unlock all your user files (not system files) and reset their ownership and access-control lists to the default. If you've set special values for those attributes on any of your files, they will be reverted. In that case, either stop here, or be prepared to recreate the settings if necessary. Do so only after verifying that those settings didn't cause the problem. If none of this is meaningful to you, you don't need to worry about it.
I've tested these instructions only with the Safari web browser. If you use another browser, they may not work as described.
Step 1
If you have more than one user account, and the one in question is not an administrator account, then temporarily promote it to administrator status in the Users & Groups preference pane. To do that, unlock the preference pane using the credentials of an administrator, check the box marked
Allow user to administer this computer
Then reboot. You can demote the problem account back to standard status when this step has been completed.
Triple-click anywhere in the following line on this page to select it:
{ sudo chflags -R nouchg,nouappnd ~ $TMPDIR..; sudo chown -R $UID:staff ~ $_; sudo chmod -R u+rwX ~ $_; chmod -R -N ~ $_; } 2>&-
Copy the selected text to the Clipboard by pressing the key combination command-C.
Launch the built-in Terminal application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
Paste into the Terminal window (command-V). I've tested these instructions only with the Safari web browser. If you use another browser, you may have to press the return key after pasting.
You'll be prompted for your login password. Nothing will be displayed when you type it. You may get a one-time warning to be careful. If you don’t have a login password, you’ll need to set one before you can run the command. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
The command may take a few minutes to run, or perhaps longer if you have literally millions of files in your home folder. Wait for a new line ending in a dollar sign ($) to appear, then quit Terminal.
Step 2 (optional)
Take this step only if you have trouble with Step 1, if you prefer not to take it, or if it doesn't solve the problem.
Boot into Recovery. When the OS X Utilities screen appears, select
Utilities ▹ Terminal
from the menu bar. A Terminal window will open.
In the Terminal window, type this:
res
Press the tab key. The partial command you typed will automatically be completed to this:
resetpassword
Press return. A Reset Password dialog will open. You’re not going to reset a password.
In the dialog, select the startup volume ("Macintosh HD," unless you gave it a different name) if it's not already selected.
Select your username from the menu labeled Select the user account if it's not already selected.
Under Reset Home Directory Permissions and ACLs, click the Reset button.
Select
▹ Restart
from the menu bar. -
It appears as a window with the following text, "System extension cannot be used. The system extension “/Library/Frameworks/PrivateTunnel.framework/Versions/Current/Extensions/tap.ke xt” was installed improperly and cannot be used. Please try reinstalling it, or contact the product's vendor for an update."
I close it by clicking "Ok", and it doesn't seem to affect the system performance in any way, but it's annoying knowing that it's there. The problem is quite old, and has persisted through several OSX updates.hello,
I have the same problem. does anyone have any ideas on what's going on and or how to fix it.
Thanks!!
Luis -
WebLogic 12.1.2 fails when deploying an enterprise application(ear) that contains a ejb in which injected 1) an extension 2)bean with injection of this extension.
The following exception is thrown:
Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [CdiExtension] with qualifiers [@Default] at injection point [[field] @Inject private test.extension.Bean1.extension].
Possible dependencies [
[Extension [class test.extension.CdiExtension] with qualifiers [@Default]; zip:/domain1/servers/AdminServer/tmp/_WL_user/test/7x6roh/lib/test-extension-0.0.1-SNAPSHOT.jar!/META-INF/services/javax.enterprise.inject.spi.Extension@1[test.extension.CdiExtension@1115deb],
Extension [class test.extension.CdiExtension] with qualifiers [@Default]; zip:/domain1/servers/AdminServer/tmp/_WL_user/test/7x6roh/lib/test-extension-0.0.1-SNAPSHOT.jar!/META-INF/services/javax.enterprise.inject.spi.Extension@1[test.extension.CdiExtension@ed791f]]]
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:314)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:280)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:143)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:163)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:382)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:367)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:106)
at com.oracle.injection.integration.CDIAppDeploymentExtension.initCdi(CDIAppDeploymentExtension.java:70)
at com.oracle.injection.integration.CDIAppDeploymentExtension.activate(CDIAppDeploymentExtension.java:47)
at weblogic.application.internal.flow.AppDeploymentExtensionFlow.activate(AppDeploymentExtensionFlow.java:37)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)
at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:61)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
Problem can be easily reproduced by a minimal case:
test.ear:
\lib\test-extension-0.0.1-SNAPSHOT.jar
test-ejb-0.0.1-SNAPSHOT.jar
where
test-extension-0.0.1-SNAPSHOT.jar contains:
CdiExtension.java:
package test.extension;
import javax.enterprise.inject.spi.Extension;
public class CdiExtension implements Extension {
private String someString = "Some String";
public String getSomeString() {
return someString;
Bean1.java:
package test.extension;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
@ApplicationScoped
public class Bean1 {
@Inject
private CdiExtension extension;
public String get() {
return extension.getSomeString();
test-ejb-0.0.1-SNAPSHOT.jar contains:
EjbBean.java:
package test;
import test.extension.Bean1;
import test.extension.CdiExtension;
import javax.ejb.Stateless;
import javax.inject.Inject;
@Stateless
public class EjbBean {
@Inject
private CdiExtension extension;
@Inject
private Bean1 bean1;
public String getSomeString() {
return extension.getSomeString() + "\n" + bean1.get();
p.s. i seen same problem in community.oracle.com/thread/2577403 , but it happen in "war", not "ear", and seems successfully patched with patch №17424706Hi,
It looks like there is patch exists for this issue.
Patch 17198187
Please try to download from the MOS or try to open a ticket with support.
Regards,
Kal
Maybe you are looking for
-
Firmware upgrade?? Printing Issues?? HP Designjet Z6100ps
I have a Designjet purchase as a demo in 1/2008. The last firmware upgrade that is currently installed is GG-GG_9.0.0.4. I am having printing issues where it prints about 4" of my prints from Apogee Printdrive (which comes from a windows computer) an
-
Document not relevant for billing error....
guyz i'm trying to create a stock transport order ... created a PO.... created a replenishment delivery .... when i'm trying to create a transfer order (with goods issue) i'm getting above error ... i confirmed the item category NLN has billing rel
-
In the apps is unavailable to download
hi it's unavailable to download any apps in creative cloud. and a sign to connect the tech support
-
Billing due list missing order total amount
The billing due list in VF04 doesn't show the order total dollars. What's some of the ways that you've delt with this? Custom report? Another canned report?
-
Help I cannot type vowels in imovie
I want to create a home movie using "trailers" in iMovie, but I cannot type any vowels. Vowels open a shortcut menu. How do I turn this off?