wood burning stoves*
The moose likes XML and Related Technologies and the fly likes XPATH/XQuery Regular Expression for replacing String pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XPATH/XQuery Regular Expression for replacing String pattern" Watch "XPATH/XQuery Regular Expression for replacing String pattern" New topic
Author

XPATH/XQuery Regular Expression for replacing String pattern

Ali Haidery
Greenhorn

Joined: Aug 23, 2013
Posts: 4
I have following xml to read:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE PROCESS_PO_007 SYSTEM "003_process_po_007.dtd">
<!-- Oracle eXtensible Markup Language Gateway Server -->
<PROCESS_PO_007>
<CNTROLAREA>..
I want to replace any comments in input xml by single space. I want to replace any tag starting with and the string in-between with a space e.g

<!DOCTYPE PROCESS_PO_007 SYSTEM "003_process_po_007.dtd"> should be replaced by ' ' similarly <!-- Oracle eXtensible Markup Language Gateway Server --> should be replace by ' '

I am using following replace function but not successful:

replace(tab.user_data.payload, '<!.*?>', ' ')
but this is not working.

Can anyone suggest what am I doing wrong here
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 499
    
    3
Do this instead?

ps: When I type in, I am forced to use double escape to tamper the rendering engine. The intention is to use the type up as so displayed.
Ali Haidery
Greenhorn

Joined: Aug 23, 2013
Posts: 4
Hi,

I am exactly doing the same as you have mentioned. The text formatter just showed it that way. But still it is not working.



g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 499
    
    3
In that case, you've to show what is actually tab.user_data.payload: I mean its syntactic meaning as appear in xquery you're using. Normally, it is slashes rather than dots and plenty of $ for variables - but cannot say must always be... Furthermore, its content I suppose is coming from a cdata section or in any case an embedded document. If not what is its content as well?
Ali Haidery
Greenhorn

Joined: Aug 23, 2013
Posts: 4
Yes, thanks for your reply.

As in my initial post for this question I have given a portion of this, this data is an xml payload for Oracle Apps Adapter which is sent in a queue. And I have to use this replace function in its de-queue condition. Below is a portion of this input:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE PROCESS_PO_007 SYSTEM "003_process_po_007.dtd">
<!-- Oracle eXtensible Markup Language Gateway Server -->
<PROCESS_PO_007>
<CNTROLAREA>..
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 499
    
    3
That put the question into a very different context than xquery. The aq supports many modes (or type? raw, varchar2, xmltype...), take note of that specificity you're working on too seems necessary.

In any case, in your dequeue procedure/function try use regexp_replace instead of replace. The pattern is good or modulo just finitely many different forms, in fact two as you surely noticed (one escape xml reserved characters, one not) and a try on both should get you going?
Ali Haidery
Greenhorn

Joined: Aug 23, 2013
Posts: 4
Yes this works as the de-queue condition of oracle apps adapter (oracle soa 11g) <property name="DequeueCondition" value="extract(xmltype(regexp_replace(tab.user_data.payload, '<!.*?>', ' ')),'//PROCESS_PO_007/DATA
 
 
subject: XPATH/XQuery Regular Expression for replacing String pattern
 
Similar Threads
Configuring Tomcat 5 on Win2K and Linux
XHTML documents vs. XHTML syntax in HTML documents
VC:Standalone Document Declaration
some notes on xml
web.xml causes 404 error