Get method ignores xml tags?
This is what I have in my little servlet:
response.setContentType("text/xml;charset=UTF-8");
PrintWriter out = response.getWriter();
String xmlRequest = request.getParameter("xml");
if (xmlRequest != null)
out.println("Client request: " + xmlRequest);
}When I tried passing the data to the server (where the servlet resides), the output on the browser shows...
Client request: hihi2
But the output that I was hoping to see is actually <test><hi>hi</hi><hi2>hi2</hi2></test> since I did the request this way: http://localhost:8084/HS/HSServlet?xml=<test><hi>hi</hi><hi2>hi2</hi2></test>
Please advise.
Thanks.
You probably want to HTML encode the XML string, like this:
<test><hi>hi</hi><hi2>hi2</hi2></test>If you have embedded the XML directly in an HTML form, then chances are the browser is filtering out the XML tags as unrecognized HTML tags. Either of these examples would pose a problem:
<form action="http://localhost:8084/HS/HSServlet">
<input name="xml" value="<test><hi>hi</hi><hi2>hi2</hi2></test>">
<input type="submit">
</form>or
<a href="http://localhost:8084/HS/HSServlet?xml=<test><hi>hi</hi><hi2>hi2</hi2></test>">Test</a>
Similar Messages
-
Adobe InDesign CS5 Server JavaScript: Get rectangle by XML tag
Hi,
Current set-up:
Adobe InDesign Server CS5 scripted through ExtendScript via PHP SOAP
The problem:
I'm currently placing an image file into a rectangle using the following code:
frame = doc.rectangles[0];
imgList = frame.place(new File(img));
This works fine; the img file is placed into the rectangle as expected. However, this only refers to the first rectangle in the document: if I have two rectangles in the document, the image is placed into the last created rectangle.
What I'd ideally like to be able to refer to the rectangle by its XML tag - something like:
frame = doc.getRectangleByTag('Pic'); // <Pic> being the name of the XML tag
imgList = frame.place(new File(img));
Does anyone have any advice as to how this can be achieved? I realise this is rudimentary question, but am finding no joy after several hours of searching.
Many thanksWhat I'd ideally like to be able to refer to the rectangle by its XML tag - something like:
frame = doc.getRectangleByTag('Pic'); // <Pic> being the name of the XML tag
imgList = frame.place(new File(img));
Are you sure you want to do it this way?
Could you explain why? I suspect there is a better solution.
In any case, at least in my test case, the XML tag is associated with the image inside the frame and not the frame itself. So if you want the frame, you must get the image associated with the tag and then go up to the parent. This works in a simple test:
var frame =
app.activeDocument.xmlElements[0].
evaluateXPathExpression("//tennis")[0].
graphics[0].parent;
[object Rectangle] -
How do I get rid of xml tags but not when the tag has copyright in it?
I tried this but it does not seem to do anything:
temp_string=temp_string.replaceAll("\\<.*?(!copyright)\\>", "");An example of this is that if I have: <meta name ="copyright" > I do not want to get rid of the tag. In other words, I do not want to get rid of any tags that have the word "copyright" in them, but I want to get rid of all other tags.
Edited by: setaret2004 on Dec 16, 2008 4:11 PMsetaret2004 wrote:
Also if I want to include license as well do I just do: str = str.replaceAll("<(?![^<>]*(copyright|license))[^<>]*>", ""); Is that correct?Yes, you can do the same thing with all three regexes. Now, explanations:
"<(?![^<>]*copyright)[^<>]*>" This regex does one lookahead, scanning forward for the word "copyright" before beginning the actual match. It's a negative lookahead, so if the word is seen, the lookahead fails and so does the overall match. If the lookahead succeeds, the match position is returned to where the lookahead started and the real matching begins.
A naïve approach would use ".*" or ".*?" in the lookahead, but then it would be free to scan past the end of the tag and find the word in the next tag or halfway through the document; lookaheads are slippery that way. But I used "[<>]*", so once it reaches the closing ">" it stops scanning.
That means, for every successful match the regex scans the whole tag twice--once for the lookahead and once "for reals". That won't be a problem in most cases, but if you're matching many large chunks of text, performance could suffer. Each of the other regexes only traverses the tag once. "<(?:(?!copyright)[^<>])*>" This one steps through the text one character at a time, at each position doing a negative lookahead before matching the character. That sounds like a lot of work, but in the vast majority of cases the lookahead will only have to look at one character before yielding.
"<(?:(?!copyright|[<>]).)*>" This is basically the same as the second regex, but it does all the real work in the lookahead. I don't recommend it; it's less readable and probably less efficient than the second regex. But both the second and third regexes can be made more efficient by using [possessive quantifiers|http://www.regular-expressions.info/possessive.html] (that whole site is highly recommended, by the way): "<(?:(?!copyright)[^<>])*+>", "");
"<(?:(?!copyright|[<>]).)*+>" The first regex can use a possessive quantifier, too, but not in the lookahead: "<(?![^<>]*copyright)[^<>]*+>" -
Get position of xml-tag in clob
Hi,
Is it possible to get the offset in a clob, representing an xml, by using xml functionality? (function or xmltable)
For example, with a clob:
v_clob := '<a><b type="1">val1</b><b type="2">val2</b></a>';I would like a function like:
v_offset := xml_offset(v_clob,'/a/b[@type="2"]');With a result of 24 to get the tag, or 35 when asking for the actual value.
Thanks,
Jan
Edited by: BluShadow on 16-Jan-2013 15:22
added {noformat}{noformat} tags for readability. Please see {message:id=9360002} and learn to do this yourself in future.p.s. if you have an unknown XML structure and you need to parse it somehow, then you will likely be best using the DBMS_XMLDOM package and treating it as a DOM document so that you can recurse the hierarchy of tags, picking out the attributes and data as you go.
ETA: Example from my library of examples...
declare
v_xml XMLTYPE := XMLTYPE('<csg>
<ecrminput id="000000001">
<xml id="001" title="CustomerId">blah blah blah</xml>
<xml id="002" title="ContactId">blah blah blah</xml>
<xml id="003" title="CustomerNo">blah blah blah0</xml>
<xml id="500" title="Attribute">blah blah blah</xml>
<xml id="500" title="Attribute">blah blah blah</xml>
<xml id="1027" title="Reservation Code">blah blah blah</xml>
<xml id="1028" title="Payment Reference">blah blah blah</xml>
<xml id="1029" title="Purchaser Customer Number">blah blah blah</xml>
</ecrminput>
<ecrminput id="000000002">
<xml id="001" title="CustomerId">blah blah blah</xml>
<xml id="002" title="ContactId">blah blah blah</xml>
<xml id="500" title="Attribute">blah blah blah</xml>
<xml id="500" title="Attribute">blah blah blah</xml>
<xml id="1027" title="Reservation Code">blah blah blah</xml>
<xml id="1028" title="Payment Reference">blah blah blah</xml>
<xml id="1029" title="Purchaser Customer Number">blah blah blah</xml>
<xml id="1016" title="Call ID">blah blah blah</xml>
</ecrminput>
</csg>');
v_xsdoc DBMS_XMLDOM.DOMDocument;
v_dn DBMS_XMLDOM.DOMNode;
PROCEDURE processnode; -- forward declaration
PROCEDURE processattributes IS
nm DBMS_XMLDOM.DOMNamedNodeMap;
attr DBMS_XMLDOM.DOMAttr;
attnode DBMS_XMLDOM.DOMNode;
attname VARCHAR2(50);
attval VARCHAR2(250);
BEGIN
nm := DBMS_XMLDOM.GetAttributes(v_dn);
FOR i IN 0..DBMS_XMLDOM.GetLength(nm)-1
LOOP
attnode := DBMS_XMLDOM.Item(nm, i);
attr := DBMS_XMLDOM.MakeAttr(attnode);
attname := DBMS_XMLDOM.GetName(attr);
attval := DBMS_XMLDOM.GetValue(attr);
dbms_output.put_line('Attribute: '||attname||' Value: '||attval);
END LOOP;
END;
PROCEDURE parse_node_element IS
eltype VARCHAR2(100);
BEGIN
eltype := DBMS_XMLDOM.GetTagName(DBMS_XMLDOM.MakeElement(v_dn));
dbms_output.put_line('Tag: '||eltype);
processattributes;
processnode;
END;
PROCEDURE parse_node_text IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Text: '||DBMS_XMLDOM.GetNodeValue(v_dn));
END;
PROCEDURE processnode IS
dnl DBMS_XMLDOM.DOMNodeList;
nt PLS_INTEGER;
BEGIN
dnl := DBMS_XMLDOM.GetChildNodes(v_dn);
dbms_output.put_line('Child Nodes Found: '||DBMS_XMLDOM.GetLength(dnl));
IF NOT DBMS_XMLDOM.IsNull(dnl) THEN
FOR i IN 0 .. (DBMS_XMLDOM.GetLength(dnl) - 1)
LOOP
v_dn := DBMS_XMLDOM.Item(dnl, i);
nt := DBMS_XMLDOM.GetNodeType(v_dn);
CASE
WHEN nt = DBMS_XMLDOM.ELEMENT_NODE THEN
parse_node_element;
WHEN nt IN (DBMS_XMLDOM.TEXT_NODE) THEN
parse_node_text();
ELSE
NULL; -- Unhandled node type;
END CASE;
END LOOP;
END IF;
END;
BEGIN
v_xsdoc := DBMS_XMLDOM.NewDOMDocument(v_xml);
v_dn := DBMS_XMLDOM.GetFirstChild(DBMS_XMLDOM.MakeNode(v_xsdoc)); -- <csg>
processnode;
END;
Child Nodes Found: 2
Tag: ecrminput
Attribute: id Value: 000000001
Child Nodes Found: 8
Tag: xml
Attribute: id Value: 001
Attribute: title Value: CustomerId
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 002
Attribute: title Value: ContactId
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 003
Attribute: title Value: CustomerNo
Child Nodes Found: 1
Text: blah blah blah0
Tag: xml
Attribute: id Value: 500
Attribute: title Value: Attribute
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 500
Attribute: title Value: Attribute
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1027
Attribute: title Value: Reservation Code
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1028
Attribute: title Value: Payment Reference
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1029
Attribute: title Value: Purchaser Customer Number
Child Nodes Found: 1
Text: blah blah blah
Tag: ecrminput
Attribute: id Value: 000000002
Child Nodes Found: 8
Tag: xml
Attribute: id Value: 001
Attribute: title Value: CustomerId
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 002
Attribute: title Value: ContactId
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 500
Attribute: title Value: Attribute
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 500
Attribute: title Value: Attribute
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1027
Attribute: title Value: Reservation Code
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1028
Attribute: title Value: Payment Reference
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1029
Attribute: title Value: Purchaser Customer Number
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1016
Attribute: title Value: Call ID
Child Nodes Found: 1
Text: blah blah blah
PL/SQL procedure successfully completed.Edited by: BluShadow on 16-Jan-2013 15:28 -
Hi,
suppose we have a xml-file looking like that.
<AAA>
<IGNORE>
</IGNORE>
<READIT>
<BB>
</BB>
<BB>
</BB>
</READIT>
</AAA>
We have an application object defined associated with the structure of <READIT></READIT> and want to read the data in IFS.
But we are not interested in data which is not between <READIT></READIT>.
So, how to say the parser to ignore anything what is not between <READIT></READIT>?
Help appreciated.
Thomas
nullRight now (i.e., in version 1.1), you can't. The parser will try to grab every element in the XML file and do something with it. In version 1.2 (soon to release), you'll be able to pick and choose which XML elements you want to parse.
-
An error with the getter method of my tag handler.
An error occurred at line: 5 in the jsp file: /tagSupportDeom.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Apache Group\Tomcat 4.1\work\Standalone\localhost\taglib\tagSupportDeom_jsp.java:62: cannot resolve symbol
symbol : class TagSupportDemo
location: class org.apache.jsp.tagSupportDeom_jsp
TagSupportDemo jspxth_tsd_TagSupportDemo_0 = (TagSupportDemo) jspxtagPool_tsd_TagSupportDemo_name_firstValue.get(TagSupportDemo.class);
^
my source :
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class TagSupportDemo extends TagSupport {
private String name;
private String firstValue;
public void setName(String name) {
this.name = name;
public void setFirstValue(String firstValue) {
this.firstValue = firstValue;
public String getName() {
return name;
public String getFirstValue() {
return firstValue;
public int doStartTag() {
pageContext.setAttribute("secondValue","value form PageContext.setAttribute()");
setValue("thridValue","value from TagSupport.setValue()");
return SKIP_BODY;
the java file can compile. but when running in jsp, it catch errors.
why?Where is PA ? I just know La because LA Lakers (I
hate this team and i like Kings and Rockets because of
YAO MING, haha )Opposite side of the country. PA stands for Pennsylvania, on the East coast. LA (Los Angeles) is in California on the West coast. Philadelphia's basketball team is the 76ers, but they don't play the Lakers,
Kings, or Rockets very often.
As for my other info, I'm sorry, I don't give that out to people. Just a personal policy. -
How to get all xml tags in a text frame?
I want to get all the xml tags of the text in a text frame. I had tried the following methods but always get the tag binding the frame itself. <br /><br />1) XMLReference objXMLRef = Utils<IXMLUtils>()->QueryXMLReferenceData(textModel, 1);<br /><br />2) XMLReference objXMLRef = Utils<IXMLUtils>()->GetStoryThreadXMLReference(textModel, textIndex);<br /><br />Thanks in advance.
I would think if you intanciate the XMLReference and use IIDXMLElement GetChildCount / GetNthChild would do what you are looking for.
Ian -
JAXB is not generating the setter method for my tag
Hi,
I am generating java classes form my .xsd file using JAXB.
The xsd definition has defnes a Form as a sequence of FormElement, where FormElement is a choice of graphical components like text etc. Form can have 0 or unbounded elements of typeFormElement
Example
<xs:element ref="sswfm:FormElement" minOccurs="0" maxOccurs="unbounded"/>
It is creating the getter method for this tag like this-
java.util.List getFormElement();
but does not create setter method, namely, setFormElements which I would like to use when marshalling from swing to XML.
If i remove the maxOccurs="unbounded, it is creating the setter method for this tag.But i want to keep this tag as it it and needs the setter method also.
What should i do? Has one tried this before. HELP if you can
Thank you in advance.Hi RavindraKshirsagar,
We have a problem like you faced. Our requirement is that, we need to generate dynamically the PERSON element in our javabean.
<xs:element name='SERVICE_REQUESTER'>
<xs:complexType>
<xs:sequence>
<xs:element ref='ORGANIZATION' />
<xs:element ref='PERSON' maxOccurs='unbounded' />
</xs:sequence>
</xs:complexType>
</xs:element>For this maxOccurs, as JAXB is not generating any Setter Method. As we need to get data dynamically from external application. If you could help us in handling this case dynamically, it will be well and good.
Please send us the script / code asap. -
I have a process that runs a SQL query and returns the results as XML. When I test the query in the Process Properties tab in Workbench it appears to execute just fine. I can also test the XML information and see that the results are coming back correctly. But when I invoke the process I get an emtpy XML tag with no results. Recording the invocation and playing back the recording doesn't tell me anything useful. Has anyone ever seen this issue before? I don't understand why everything within the process seems to bring back results just fine but invoking it returns nothing.
Unfortunately I am not the admin for our LiveCycle instance and do not have access to the server logs (long story). I also am not authorized to share any LCA files for this project. Thanks though.
-
Remove Empty XML Tags using module parameters
Hi All,
In my lanscape I have two PI Systems.
My scenario is an IDOC reaches 1st PI system gets converted into an EDIFACT and then goes to the 2nd PI and from there it gets routed to the respective AS2 Party.
I am using SOAP to pass message between the PI systems and B2B Toolkit's AS2 Adapter for the communication with AS2 party.
The issue is when the message is getting converted from IDOC to EDIFACT there are a few feilds with occurence 1..1 and due to these fields i get an empty XML tag at the output. These empty XML tags give me an error in the B2B Toolkit's AS2 Adapter Receiver Channel
I cannot change the occurence in the structure of the EDIFACT nor can I use an XSLT mapping to remove empty tags before the message reaches the Communication Channel.
I want to know if there are any module parameters which i can use either in SOAP Channel or the AS2 Channel to remove the XML Tags.Hi Muni,
"1..1 means, you must send some values for that fields. try to find out why these are not getting any values."
This empty tag is expected. Before using B2B Toolkit's AS2 Adapter we used to use Seeburger's AS2 Adpater and the message used to get executed successfully with these empty tags.The issue is coming only when we are using B2B Toolkit's AS2 Adapter.
"if you want to stop sending(the fields which are not needed in target) you can you can disable the fields in the message mapping."
I cannot disable the feild in the mapping as some other message may use this field.
Thanks,
Farhaan -
Want to include ?xml tag and schema when creating XML
My database table that need to be generated in to XML are large and therefore I must use OracleXMLQuery.getXMLSAX . The output is missing the <?xml version="1.0" ?> tag. How do I get it? I am on 9i but have imported the .jar containing oracle/xml/parser/v2/XMLSAXSerializer from 10g XDK.
Also, I want the schema to be written next, before the actual XML table values.
I know that a command line parameter exists, which works for small XML files:
java oraclexml getxml -user "scott/tiger" -withDTD "select ....
How do I get the equivalent of '"-withDTD" when using
OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from "+table_name );
qry.getXMLSAX(myStream);
myStream.flush();
Thank you,
ElaineNo. Actually, I can get the <?xml tag and DTD if my select statement contains 'where rownum=0', as the resultset is small which lets me use getXMLMetaData() .
I write it to one output file, then do another OracleXMLQuery, repeating the select statement without the where clause, and run that through getXMLSAX to get the detail.
Next, I need to scrub the data of special characters acceptable in the database but which cause problems to a browser or XML validator. (e.g. accented characters).
Finally, I will concatente the two files.
Is there a simpler way to do this?
Thanks,
Elaine -
Getting the 'name' of an XML tag
I am trying to get the 'name' value out of an XML tag. Here is the XML that I am parsing:
<param name="param_name">param_value</param>
I can get the values 'param' and 'param_value' using the node.getNodeName() and the node.getNodeValue() methods.
I need the value of "param_name" though because in the situation that I am in, this is how the node values are determined.
Any thoughts? Thanks in advance!Hello,
"name" is called an attribute of the "param" element. You could try to take a look at the getAttributes() function (node.getAttributes().item(0)).
I hope it helps. -
Getting unwanted values between the XML tags in XSLT mapping
Hi Folks
I have come across a very strange situation with my xslt mapping.
I am getting unwated values "11" between xml tags
as follows
<Tag>0001</Tag>
11
<DataID>3</DataID>
I am not sure why I am getting these values in between the tags. Any suggestions would be appreciated.Hi David,
Here is the code fragment where these 2 tags are mapped, FYI, the source is an IDOC message. The unwanted "11" is coming After the <Tag></Tag> and <DataID></DataID>. FYI, Fof the element <Tag></Tag> its a default value. But for <DataID> </DataID> I have the mapping logic.
<Order>
<OrderHeader>
<Tag>009</Tag>
<xsl:for-each select="E1EDKA1">
<xsl:choose>
<xsl:when test="normalize-space(PARVW) = 'WE' and normalize-space(LIFNR) = 'U960'">
<DataID>
<xsl:value-of select="'1'" />
</DataID>
</xsl:when>
<xsl:when test="normalize-space(PARVW) = 'WE' and normalize-space(LIFNR) = 'U300'">
<DataID>
<xsl:value-of select="'3'" />
</DataID>
</xsl:when>
<xsl:when test="normalize-space(PARVW) = 'WE' and normalize-space(LIFNR) = 'U930'">
<DataID>
<xsl:value-of select="'1'" />
</DataID>
</xsl:when>
<xsl:when test="normalize-space(PARVW) = 'WE' and normalize-space(LIFNR) = 'U400'">
<DataID>
<xsl:value-of select="'3'" />
</DataID>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'1'" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each> -
How to get the value in the XML tag?
hi all,
i am new to JAXP. i tried the sample program provided in the following link. it just counts the number of tags in the XML file. XML file name is given as command line argument.
Now, if i want to display the value in the XML tag( say <NAME>xxx</NAME> in this tag i want to display the value 'xxx' ), what has to be done?
how can i achieve this?
please help...
link of the sample program:
http://xml.apache.org/~edwingo/jaxp-ri-1.2.0-fcs/samples/SAXLocalNameCount/SAXLocalNameCount.java
thx in advance,
-Soni.implement this method the same way you have startElement...
public void characters(char[] ch,
int start,
int length)
throws SAXException -
Hi,
I am trying to get the attribute values of an XML Tag of a Textbox. To get the xml tag of the selected element, I use
InterfacePtr<IXMLTagSuite> xmlTagSuite(fCurrentSelection,UseDefaultIID());
if (xmlTagSuite)
UIDList tagUIDList = xmlTagSuite->GetTags();
UID tagID;
UIDRef tagUIDRef;
for(int32 i=0; i < tagUIDList.Length();i++)
tagID = tagUIDList[i];
tagUIDRef = UIDRef(fCurrentSelection->GetDataBase(), tagID);
InterfacePtr<IXMLTag>xmlTag(tagUIDRef,UseDefaultIID());
if (kTrue == tagUIDRef.ExistsInDB()) {
tagName = xmlTag->GetTagName();
err = kSuccess;
since I am totally new to this, It would help a great deal if you could tell me how to iterate thourgh the attribute values of that tag.
Thanks so much in advance
Benny"Tags" are what appear in the Tags palette. "Elements" are what appear in the Structure View. Tags do not have attributes, elements are the ones with attributes. Instead of looking at the tags, you should be looking for the elements. Find the element that's associated with the story, and IIDXMLElement should have attributes you can loop through.
Maybe you are looking for
-
Error in Email via spool list recipient feature in SM37
Hello Experts. I encounter a strange problem. I am not able to send Email to external Email addresses (Lotus Notes) while I am using Distribution list option in spool list recipient option in SM37 background job. I am getting an error in SOST called
-
I sent email from my droid it gets to my computer saying its ready to print never does.
-
Cannot create billing document due to errors
Hi, I cannot creat the billing document due to below errors in the error log of VF01. I ran SDRQ report and cannot detect any inconsistency. Error Log 4 0025001049 0
-
I am looking for some white papers / blogs on calling SAP Enterprise Services via PI. I would also like to get sdome idea of the following points: 1) A typical scenario using Enterprise Services 2) Is it possible to extend Enterprise Services as one
-
BOM IDOC : BOM send with delta
Hello, I have a BOM with 2 composants. When I modify one of the composant of the BOM, the IDOC created contains only the modification. The composant which was not modified is not sent. The delta mode seems to be activated. How I can desactivate it. I