Transform XML and display xsl:message
Hi,
I have a simple method to transform XML. My XSLT has <xsl:message> to help debugging while transforming. How do I access the messages to System.out.printLn?
public static Document transformXML(Document xmlDoc, Document xslDoc) throws XMLHelperException {
try {
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new DOMSource(xslDoc));
DOMResult result = new DOMResult();
transformer.transform(new DOMSource(xmlDoc), result);
org.w3c.dom.Node resultNode = result.getNode();
if (resultNode instanceof Document) return (Document)resultNode;
else return result.getNode().getOwnerDocument();
} catch (TransformerConfigurationException ex) {
throw new XMLHelperException("Unable to perform transform " + ex.getLocationAsString(), ex);
} catch (TransformerException ex) {
throw new XMLHelperException("Unable to perform transform " + ex.getLocationAsString(), ex);
}thanks for the help.
Edited by: bonekrusher on Mar 8, 2008 2:27 PM
Edited by: bonekrusher on Mar 8, 2008 2:27 PM
public class XForm {
public static void main(String[] args) throws Exception {
InputStream xslStream = null;
InputStream xmlStream = null;
try {
TransformerFactory tf = TransformerFactory.newInstance();
xslStream = new BufferedInputStream(new FileInputStream(args[1]));
Transformer t = tf.newTransformer(new StreamSource(xslStream));
tf.setErrorListener(new ErrorListener() {
public void error(TransformerException ex) throws TransformerException {
ex.printStackTrace();
public void fatalError(TransformerException ex) throws TransformerException {
ex.printStackTrace();
public void warning(TransformerException ex) throws TransformerException {
ex.printStackTrace();
xmlStream = new BufferedInputStream(new FileInputStream(args[0]));
t.transform(new StreamSource(xmlStream), new StreamResult(System.out));
} catch (Exception e) {
e.printStackTrace();
} finally {
if (xslStream != null)
xslStream.close();
if (xmlStream != null)
xmlStream.close();
<test>
<sample try="yes">
a
</sample>
</test>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan">
<xsl:template match="/">
<xsl:message terminate="no">got here</xsl:message>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*|@*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:transform>
Similar Messages
-
My Ipad is locked and display a message that says " The Ipad hasnt been backed up in 2 weeks...........connected to wifi". How do I come out of it?
Reset iPad
Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
Note: Data will not be affected. -
How to stop a process from running and display a message
I have a button that inserts data into a table based on bind variable selected on the page. I would like to add code to that button that will check to see if certain data already exists in the table, for that bind variable, and if that data already exists, stop the process and display a message that says "you have already inserted that information - bla bla bla". If not, continue inserting. What would be the best way to do this?
Currently, the button is a plsql that inserts the data.
Any help or examples would be greatly appreciated!
mholman
Edited by: user10488561 on Jul 27, 2009 8:48 AMUse a validation process for that. If the validation fails (data exists) the processes will not be run. If it doesn't then the processing will continue.
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------------------ -
How to validate VO result and display error message?
Hi,
I have created 2 pages:
Page 1: User to enter employee number and click 'Go' button to search (redirect to Page 2)
Page 2: To display employee details
In situation where employee is suspended, employee detail will be display as blank in Page 2.
At the same time, we would like to display error message which inform user to refer to HR Department for this scenario.
Need guidance on how to perform the validation and display error message.
Thanks and Regards,
Shiau ChinHi Shiau,
In this case instead of redirecting to next page, throw an exception on the same page.
If you want redirect it to next page then while redirecting it to next page pass some info that can indicate that employee is suspended, get this value in Process request if it has value then throw exception else query details.
Regards,
Reetesh Sharma -
I have created a DVD via iMovie and burned several copies. It is a large file. When played the some DVD's will stop and display a message SKIPPING DAMAGED Part but will not resume. Some work fine. It is not the DVD. I have burned from several batches. When trying to export the project, I get an error message with the following message: The project could not be prepared for publishing because an error occured (-108).
TV video typically is copyrighted content. We'd be breaking several rules trying to help you. Good luck!
-
I have been using CS6 for two years without incident. Suddenly the Media Encoder stops working, showing APPCRASH and displaying error message about WatchFolder.dll - I tried uninstalling and re-installing to no avail - can anyone help?
Hi Mylenium,
Thanks for your response.
Here is the error information showing up:
Problem signature:
Problem Event Name: APPCRASH
Application Name: Adobe Media Encoder.exe
Application Version: 6.0.0.382
Application Timestamp: 4f62fcf1
Fault Module Name: WatchFolder.dll
Fault Module Version: 6.0.0.382
Fault Module Timestamp: 4f62f37f
Exception Code: c0000005
Exception Offset: 0000000000007899
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 4105
Additional Information 1: 9a62
Additional Information 2: 9a620826d8ae4a2fa8b984b39290a503
Additional Information 3: 1fb3
Additional Information 4: 1fb304eee594288faeefbf1271b70d37
I am using a PC Windows 7 -
hello
I can't reinstall osx lion from internet, and display a message"cannot find installation information ,please contact applecare, what should i do?
thanksI'm no Lion expert, but I believe you can boot from the Recovery partition by pressing the Command and R keys on startup, then reinstall.
-
The Problem/s
1. I am unable to sync my iPhone 4S with my Mac Book Pro, either by cable, wifi or bluetooth
2. iTunes will initiall open and briefly identifies the iPhone in the Device section in iTunes.
3. When iTunes starts to read the iPhone (displaying the spinning wheel), it immediately then quits and
4. Opens a 'dialogue box' which displays the message "iTunes Quit Unexpectedly"
5 The dialoge box offers the following button options to:-
'Show Details'
The 'Show Details' button will open and display a list of the 'Problem Details and System Configeration'. To the average user the information is useless, as one doesn't know what to look for to solve the problem. This is a long and detailed report (too long to include in this message), which includes information such as:-
Crashed Thread: 20
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000000006f0
'OK'
The 'Ok' button simply quits and closes the dialogue box
'Reopen'
The 'Reopen' button will again reopen iTunes, briefly showing that it is trying to read the iPhone in the Devices section, but then returns again to display the same dialogue box.
Other Information
1. iTunes will still start normally once the USB cable is removed from the Mac book Pro, but crashes again once the USB cable is reattached to the computer
Any advice or help offered would be greatly appreciated.
Sincerely
Rob
Message was edited by: RobmanricoHi there anaqeed,
I would recommend taking a look at the troubleshooting steps found in the article below.
Issues installing iTunes or QuickTime for Windows
http://support.apple.com/kb/ht1926
-Griff W. -
How to compare two currency form fields and display a message if the fields do not equal?
My form has 2 fields named Total_1 and Total_2. If one of the fields does not equal the other, a hidden field will display a message in red on the form alerting the user. Otherwise, the message does not display. Looks like a validation script but I would greatly appreciate help in getting it started. Any ideas?
Thanks, Charlie
charlie6067Since the field values that you want to compare are the results of calculations, you should not normally compare their string values, but rather their numeric values when rounded appropriately (and perhaps then converted to a string). For example, if you have two values that display as 3.14, one could be 3.1400000001 and the other could be 3.13999999999991234. When you get the field values as strings and compare them, they won't be equal though they appear to be. Even some values that are numerically identical won't be equal when compared as strings ("0.0" != "0.00") So the code could be changed to:
// Get the two field values, rounded to two decimals
var v1 = util.printf("%.2f", getField("Total_1").value);
var v2 = util.printf("%.2f", getField("Total_2").value);
// Hide/Show the error message
event.value = (v1 === v2 || (+v1 === 0 && +v2 === 0)) ? "" : "Error message here."; -
Check File Existence and display alert message
Hi,
I have a servlet which uploads file to server. Below is my code and is working file. Now, I want to check if the file uploading by the user is already exists. If so , I have to display a message to user "The file you are trying to upload already exists. Do you want to overwrite" with YES or NO actions.
How can I display this alert message from user.
//item.write(tosave);
FileItemFactory factory = new DiskFileItemFactory();
boolean isMultipart = FileUpload.isMultipartContent(request);
System.out.println(isMultipart);
Map fileDetails = new HashMap();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = upload.parseRequest(request);
Iterator iter = items.iterator();
while (iter.hasNext()) {
item = (FileItem) iter.next();
if (item.isFormField()) {
String fieldName = item.getFieldName();
String fieldValue = item.getString();
fileDetails.put("fileName",item.getString());
else {
fileDetails.put("path",item.getName());
cfile=new File(item.getName());
onlyFileName = cfile.getName();
if (! folder.exists()) folder.mkdirs();
if(cfile.exists()){ //THIS CHECK THE FILE EXISTENCE. HOW CAN I DISPLAY ALERT MESSAGE TO USER HERE.
System.out.println("File Already Exists Path is ");
Can anyone suggest me on this.It won't work like that because JavaScript will run either before the form is submitted or after the page has been generated. In either case, you can't really communicate between the server side code and client side code.
What you can do is use Ajax to communicate with a servlet that checks for the duplicate file and responds accordingly. You can then perform the appropriate action on the page. This should be very simple to setup, take a look at this basic tutorial [1].
[1] http://www.w3schools.com/ajax/default.asp
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://www.catb.org/~esr/faqs/smart-questions.html
---------------------------------------------------------------- -
Scan through the records in the Form and display the message!
Hello Everyone,
We have a requirement, I do not know how to achieve it.
In a Forms 6i, 2 fields Type, Comment.
Type is a list of Values (1,2,3)
Comment - Free Text Field.
User can enter as much rows of data, but while user saves the data we have to validate that all the records of Same Type(Say 1). If not we have to display a Message.
So how to achieve this? How to scan through the records in the Form. Any comments on it would be great.
Thanks.User can enter as much rows of data, but while user saves the data we have to validate that all the records of Same Type(Say 1). If not we have to display a Message.I am assuming that you want to check from the first record. Suppose in first record the user coosed 1 and you will check for all the entries for 1.
Couple of ways to do this.
1. While user is entering first record. You can keep that selected type value in GLOBAL variable and while he is entering further records you can match type with that global variable. If it is not matching then you can display message.
2. On KEY-COMMIT trigger you can start loop from first record and can check for all the records one by one. Like.
DECLARE
vVal DATATYPE;
BEGIN
GO_BLOCK('BLOCK_NAME');
FIRST_RECORD;
vVal:=:FORM_TYPE_FIELD;
LOOP
IF vVal!=:FORM_TYPE_FIELD THEN
MESSAGE(..);
EXIT;
END IF;
EXIT WHEN :SYSTEM.LAST_RECORD='TRUE';
NEXT_RECORD;
END LOOP;
END;I would go for earlier approach and will use WHEN-VALIDATE-ITEM / PRE-INSERT for type field for this purpose. Because in KEY-COMMIT the system is doing same thing again.
-Ammad
Edited by: Ammad Ahmed on May 15, 2010 12:23 AM
changes not equal sign to != -
How do I save and display all messages in non primary email address
I have 2 email accounts on Thunderbird. The emails to the secondary account are not saved. I can open and read new messages but if I want to view them later, they are gone. My primary email retains all messages. Can I configure Thunderbird so I can retain all messages on more than one email account? If so, How?
There are several possible reasons that messages seem to 'disappear'.
There are two types of email accounts: IMAP and POP. See https://support.mozilla.org/en-US/kb/glossary-terms-including-types-accounts
If you have a POP account and are accessing the mail on more than one computer or smartphone, whichever device reads (downloads) the message first will have it locally, but it will no longer be listed or available on the other devices.
If you have an IMAP account, the message stays on the server, but if one device (user) moves or deletes the message, it will affect the view on all devices. So, for example, if you are using your smartphone and take some action on an email, when you get back to your computer, it will reflect that same action (but you might not have realized what caused it).
Another, less likely, reason for messages not to show up in your inbox is having the preference set to show only unread or recent messages. Then once you read them they seem to disappear.
If you are still having problems, please look at the following items and respond with the information.
1) What operating system do you use (Win8, MAC, Linux, etc)?
2) Are you using IMAP or POP?
3) If your mail server has a browser interface (web mail access such as mail.google.com), do the messages show up there?
4) Right click on the folder in question and select Properties.
a) Number of messages?
b) Size on disk?
5) Left click on the account name; View settings for this account; highlight Server settings;
What choices are marked under "When I delete a message"?
6) What, if any, antivirus program do you have installed? -
Transforming xml and DataGrids
Hello
I am reading data from a large xml file. I read it in using
HTTPService and the result type is "E4X". It contains information
about items in a warehouse.
like this
<Inventory>
<warehouse name="Texas">
<chairs count="900"/>
<tables count="40"/>
<lamps count="200"/>
</warehouse>
<warehouse name="California">
<chairs count="20"/>
<tables count="200"/>
<lamps count="1"/>
</warehouse>
</Inventory>
So far I have been able to show a list of warehouses in a
mx:List control and then when I select a warehouse (texas in this
case) I would like to display the list of items and their counts in
an mx:DataGrid control.
I can see that I can use selectedItem of the mx:List to
return the Node for the Texas warehouse like this
<warehouse name="Texas">
<chairs count="900"/>
<tables count="40"/>
<lamps count="200"/>
</warehouse>
But how can I get the data to display in a data grid
ITEM COUNT
chairs 900
tables 40
lamps 200
Thanks
ToddNot familiar with stxx, but it should allow you the use of the xsl:strip-space instruction or some equivalent, when the XSLT is applied to the XML for transformation...
-
How to cancel the event in Item Adding without going to the SharePoint Error Page?
Prevent duplicate item in a SharePoint List
The following Event Handler code will prevent users from creating duplicate value in "Title" field.
ItemAdding Event Handler
public override void ItemAdding(SPItemEventProperties properties)
base.ItemAdding(properties);
if (properties.ListTitle.Equals("My List"))
try
using(SPSite thisSite = new SPSite(properties.WebUrl))
SPWeb thisWeb = thisSite.OpenWeb();
SPList list = thisWeb.Lists[properties.ListId];
SPQuery query = new SPQuery();
query.Query = @"<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + properties.AfterProperties["Title"] + "</Value></Eq></Where>";
SPListItemCollection listItem = list.GetItems(query);
if (listItem.Count > 0)
properties.Cancel = true;
properties.ErrorMessage = "Item with this Name already exists. Please create a unique Name.";
catch (Exception ex)
PortalLog.LogString("Error occured in event ItemAdding(SPItemEventProperties properties)() @ AAA.BBB.PreventDuplicateItem class. Exception Message:" + ex.Message.ToString());
throw new SPException("An error occured while processing the My List Feature. Please contact your Portal Administrator");
Feature.xml
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="1c2100ca-bad5-41f5-9707-7bf4edc08383"
Title="Prevents Duplicate Item"
Description="Prevents duplicate Name in the "My List" List"
Version="12.0.0.0"
Hidden="FALSE"
Scope="Web"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml"/>
</ElementManifests>
</Feature>
Element.xml
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="100">
<Receiver>
<Name>AddingEventHandler</Name>
<Type>ItemAdding</Type>
<SequenceNumber>10000</SequenceNumber>
<Assembly>AAA.BBB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8003cf0cbff32406</Assembly>
<Class>AAA.BBB.PreventDuplicateItem</Class>
<Data></Data>
<Filter></Filter>
</Receiver>
</Receivers>
</Elements>
Below link explains adding the list events.
http://www.dotnetspark.com/kb/1369-step-by-step-guide-to-list-events-handling.aspx
Reference link:
http://msdn.microsoft.com/en-us/library/ms437502(v=office.12).aspx
http://msdn.microsoft.com/en-us/library/ff713710(v=office.12).aspx
Amalaraja Fernando,
SharePoint Architect
Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.Recommended way for binding the list event handler to the list instance is through feature receivers.
You need to create a feature file like the below sample
<?xmlversion="1.0"encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="{20FF80BB-83D9-41bc-8FFA-E589067AF783}"
Title="Installs MyFeatureReceiver"
Description="Installs MyFeatureReceiver" Hidden="False" Version="1.0.0.0" Scope="Site"
ReceiverClass="ClassLibrary1.MyFeatureReceiver"
ReceiverAssembly="ClassLibrary1, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=6c5894e55cb0f391">
</Feature>For registering/binding the list event handler to the list instance, use the below sample codeusing System;
using Microsoft.SharePoint;
namespace ClassLibrary1
public class MyFeatureReceiver: SPFeatureReceiver
public override void FeatureActivated(SPFeatureReceiverProperties properties)
SPSite siteCollection = properties.Feature.Parent as SPSite;
SPWeb site = siteCollection.AllWebs["Docs"];
SPList list = site.Lists["MyList"];
SPEventReceiverDefinition rd = list.EventReceivers.Add();
rd.Name = "My Event Receiver";
rd.Class = "ClassLibrary1.MyListEventReceiver1";
rd.Assembly = "ClassLibrary1, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=6c5894e55cb0f391";
rd.Data = "My Event Receiver data";
rd.Type = SPEventReceiverType.FieldAdding;
rd.Update();
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
SPSite sitecollection = properties.Feature.Parent as SPSite;
SPWeb site = sitecollection.AllWebs["Docs"];
SPList list = site.Lists["MyList"];
foreach (SPEventReceiverDefinition rd in list.EventReceivers)
if (rd.Name == "My Event Receiver")
rd.Delete();
public override void FeatureInstalled(SPFeatureReceiverProperties properties)
public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
}Reference link: http://msdn.microsoft.com/en-us/library/ff713710(v=office.12).aspxOther ways of registering the list event handlers to the List instance are through code, stsadm commands and content types.
Amalaraja Fernando,
SharePoint Architect
Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights. -
Getting Email Value from web.xml and displaying in JSF
HI,
I have a web.xml with the entry:
<env-entry>
<description>The email address for the Support Team.</description>
<env-entry-name>support</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>[email protected]</env-entry-value>
</env-entry>I want to display on the JSF the value *"[email protected]"*. I dont want to Hard Code the Email Id on the JSF hence I am looking for this solution.
One way would be to get the value of the email in a backing bean and then setting a managedBeanValue which will be accessed in the JSF Display page.
My question is how do I get the email value in my backing bean ?
Thanks in advance !!!I tried using this code:
FacesContext context = FacesContext.getCurrentInstance();
ServletContext servletContext = (ServletContext)context.getExternalContext().getContext();
String value = (String)(servletContext.getAttribute("support");But when I do a System Out on value I get null
Please Help.
Thanks in advance
Maybe you are looking for
-
How to give other material as a free good
Hi all, Here i am getting doubt how to give free good for one material to another material. for ex:- if customer buy product A he will get product B as a free good how do we configure in to sap. i tried in exclusive method in the sales order it is ex
-
N8 music player has to refresh library every time ...
N8 music player has to refresh library every time after switching on the phone. why?
-
How can i download data service 3.1 for win2003 64bit
Hi All How can i download data service 3.1 for win2003 64bit I can't find it from service marketplace (only for 32 bit) Thanks
-
CC app says AE is installed - it's not, and I can't download it!!!
I got a sweetpea error on AE and it stopped working. I uninstalled it, and now the CC app says it is installed and I can't re-install it. I'm on Maverics 10.9 on a 2.6GHz Oct 2013 MBP. Please help! I have a deadline to meet!!! Thanks
-
Enterpirse manager doesn't start
Hi all When I try to start the Enterprise manager through the "start \ run \ emctl start dbconsole" option nothing happens. For a brief moment a dosbox appears, and that's it. Am I missing part of the installation or is there something else I need to