XPath to capture nodes between two nodes

Hi all

I met a problem a seemingly simple challenge of mine.

I have the following xml code.

Basically, I would like to capture the text between the begin-end blocks

<? XML version = "1.0" encoding = "UTF-8"? >

< document >

< body >

< paragraph >

< run >

< fld type = 'start' / >

< / run >

< run >

< text > SAMPLE < / text >

< / run >

< run >

< text > < / text >

< / run >

< run >

< text > FIELD < / text >

< / run >

< run >

< fld type = 'end' / >

< / run >

< run >

< text > TEXT UNWANTED SOME < / text >

< / run >

< / paragraph >

< paragraph >

< run >

< fld type = 'start' / >

< / run >

< run >

< text > SAMPLE < / text >

< / run >

< run >

< text > < / text >

< / run >

< run >

< text > Field2 < / text >

< / run >

< run >

< fld type = 'end' / >

< / run >

< run >

< text > TEXT UNWANTED SOME < / text >

< / run >

< run >

< fld type = 'start' / >

< / run >

< run >

< text > SAMPLE < / text >

< / run >

< run >

< text > < / text >

< / run >

< run >

< text > FIELD3 < / text >

< / run >

< run >

< fld type = 'end' / >

< / run >

< / paragraph >

< / body >

< / document >

So far, what I came up with is:

WITH temp AS (
SELECT 
       XMLTYPE ('<?xml version="1.0" encoding="UTF-8"?>
                  <document>
                     <body>
                        <paragraph>
                           <run>
                              <fld type="begin" />
                           </run>
                           <run>
                              <text>SAMPLE</text>
                           </run>
                           <run>
                              <text> </text>
                           </run>
                           <run>
                              <text>FIELD</text>
                           </run>
                           <run>
                              <fld type="end" />
                           </run>
                           <run>
                              <text>SOME UNWANTED TEXT</text>
                           </run>
                        </paragraph>
                        <paragraph>
                           <run>
                              <fld type="begin" />
                           </run>
                           <run>
                              <text>SAMPLE</text>
                           </run>
                           <run>
                              <text> </text>
                           </run>
                           <run>
                              <text>FIELD2</text>
                           </run>
                           <run>
                              <fld type="end" />
                           </run>
                           <run>
                              <text>SOME UNWANTED TEXT</text>
                           </run>
                           <run>
                              <fld type="begin" />
                           </run>
                           <run>
                              <text>SAMPLE</text>
                           </run>
                           <run>
                              <text> </text>
                           </run>
                           <run>
                              <text>FIELD3</text>
                           </run>
                           <run>
                              <fld type="end" />
                           </run>
                        </paragraph>
                     </body>
                  </document>') AS xml_template
FROM dual
)
SELECT x.*
  FROM temp
      ,XMLTABLE('//*/paragraph/run[fld/@type="begin"]/following-sibling::run[following-sibling::run[fld/@type="end"]]/text'
                PASSING temp.xml_template
                COLUMNS res varchar2(100) PATH '.'
               )x

Result:

RES

SAMPLE

FIELD

SAMPLE

FIELD2

SOME UNWANTED TEXT

SAMPLE

FIELD3

Unfortunately what I wrote XPath is not good enough, because with regard to the text between the two blocs of start-end it still captures the unwanted text.

My XPath knowledgege dept unfortunately not so I would appriciate annything you can help me with even an idea could get through on the edge.

Thank you

Steve

Steve,

XQuery can help in this case:

SELECT x.*
FROM temp
   , XMLTABLE('for $begin in /document/body/paragraph/run[fld/@type="begin"]
               let $end := $begin/following-sibling::run[fld/@type="end"][1]
               return $begin/following-sibling::run[. << $end]'
       PASSING temp.xml_template
       COLUMNS res varchar2(100) PATH 'text'
     ) x  ;

Explanation:

This FLWOR expression traverses all nodes 'start' in the document, finds the corresponding node of the 'end' and returns the sequence of "run" nodes follows 'begin' and above 'end '.

If you want to concatenate all the fragments of text in a block, you can also do it directly, like this:

for $begin in /document/body/paragraph/run[fld/@type="begin"]
let $end := $begin/following-sibling::run[fld/@type="end"][1]
return string-join($begin/following-sibling::run[. << $end]/text, "")

She's going back 3 ranks:

RES

-------------

EXAMPLE OF A FIELD

SAMPLE FIELD2

SAMPLE FIELD3

Tags: Oracle Development

Similar Questions

  • Connectivity between two nodes of Virtual Box

    For a few days, I try to establish the network connectivity between two nodes OEL (Oracle Enterprise Linux) in Oracle Virtualbox. I tried everything I have found Google, but still nothing works, everytime I try to ping from one node to another node Hostname/IP is showing unknown host. All the advice everyone here will be great for me.

    Published by: 918868 on October 30, 2012 02:30

    When you create a virtual machine, by default VirtualBox allows virtual network card and selects the "Network Address Translation" (NAT) mode for it. In this way the guest can connect to the outside world using the networking of the host and the outside world can connect to services on the feedback that you choose to make visible outside of the virtual machine.

    This default configuration is good probably 95% of users of VirtualBox. VirtualBox is, however, extremely flexible in how it can virtualize networks. It supports multiple virtual NICs per virtual machine, the first four that can be configured in detail in the Manager window. Additional network cards can be configured on the command-line with VBoxManage.

    Source: http://www.virtualbox.org/manual/ch03.html#settings-network

    For more details, please see:

    Virtual networks
    http://www.VirtualBox.org/manual/CH06.html

    Concerning
    Girish Sharma

  • GPIB communication between two computers

    I try to communicate between two computers via GPIB. A computer to send an order, the other will receive, save and then respond accordingly. This response will then be received by the first computer and displays (this is the emulation of a device, the real need is to communicate with a satellite TT & C)

    I realized all of this. However, to be in listening mode I wired a property node with a timeout-infinity (1) before reading. Now I can't leave the VI as he is still stuck in playback until the receipt of an order.

    How can I get out of the VI when he's stuck in playback function.

    PS: Using GPIB for communication is a requiremnet of ht eproect and cannot be replaced.

    Hello

    You can have the timeout of read and then clear the error and keep looping until you get a message.  And then you can use arithmetic consisting of stop the loop if you click on the stop button, or get one error other than a timeout, or if playback returns data.

    If it works for you?  I joined your 'writing and then read.vi' with the added code.  Double check my logic, I'm sure it's just but not run it.  Also, if you return a large amount of data make sure that the time-out period is sufficient.

  • Regular expression help please. (extraction of a subset of the string between two markers)

    I haven't used regular expressions before, and I can't find a regular expression to extract a subset of the string between two markers.

    The chain;

    Stuff of header I want
    Stuff of header I want
    Stuff of header I want

    Stuff of header I want
    Stuff of header I want
    Stuff of header I want

    6 ERRORS
                         
    Info I want to line 1
    Info I want line 2
    Info I want line 3
    Info I want to line 4
    Info I want to line 5
    Info I want line 6
    END_ERRORS

    From the string above (it is read from a text file), I try to extract the subset of string between ERRORS 6 and END_ERRORS. The number of errors (6 in this case) can be any number from 1 to 32, and the number of lines I want to extract will correspond with this number. I can provide this number of a caller VI if necessary.

    My current solution, which works, but is not very elegant;

    (1) using Match Regular Expression for the return of the string after you have synchronized the 6 ERRORS

    (2) uses the Regular Expression matches to return all characters before game END_ERRORS of the string returned by (1)

    Is there a way this can be accomplished using 1 Regular Expression Match? If so someone could suggest how, as well as an explanation of the work of the given regular expression.

    Thank you very much

    Alan

    I used a character class to catch any word or whitespace characters.  This put inside parentheses a substring matching the criteria that you can get by developing the node for regular expression matching.  The \d matches the numbers and the two * s repetition of the previous term.  So, \d* will find the '6', as well as "123456".

  • Build a private network between two physical hosts in ESXi 4.0 for VM guests

    Hi all

    I am a newbie in the use of VMWare ESXi for my company testings and I have a question on networks

    in ESXi. In fact, I always do my tests in my VMware Workstation, and it's pretty easy to build a virtual

    private network between two guests of computer virtual and it needed to do more real testings on ESXi environment.

    But now I have two Dell servers mounted and with two ESXi 4.1 installed on these servers.

    Each server has two network cards connected to the same network switch.

    In this essay, I have to install a RAC Oracle 11 g as guests of virtual computer on two separate server Dell for

    two RAC nodes.

    The installation Guide for the PAP, I need to build a network between two nodes.

    My superficial knowledge network, the private network address is not the same as

    the public network address, in this case, the IP address provided by the network switch is

    10.1.10.X and it should be public network address.

    In this case, how can I do the private network of ESXi settings?

    I do the settings of the network switch? I'm not the guy of networking and really

    want your expertise in this area.

    If you have an idea or experience to share, please kindly help.

    Thank you very much

    Ray

    SonyRaymond wrote:

    Then private network can be established between NIC (N1) and NIC (N2) with address 192.168.1.X

    range?

    Yes, that's correct. It would have made you have a private network layer 3 between the two guests in the 192.168.1.x address range.

    In general, you also want to isolate a layer 2 (ethernet) with the VLANS on the physical switch, but if this is not possible at this time then it could be implemented now and you could later add VLAN in the switch.

    It is also the reason why I think you should create a new portgroup on the same vSwitch as other existing exchanges. If you later configure VLAN to the physical switch, it will be very easy to activate this on the "private" portgroup

  • Measure the time between two digital pulse

    Hello

    For a non-critical calendar application, I need to measure the time interval between consecutive TTL pulses, ranging from the order of 0.5 s for a few seconds, with a low accuracy of +/-10-50ms. The interval being measured varies between the rising edge of the first pulse and the front of the next and so on.

    I have several input lines I need to deal with. Because it's a critical machination low cost, I don't want to use digital counters for each line, so I work with an acquisition of data USB6008 and have connected the input rows TTL on the digital inputs of the device. Avoiding will be sufficient.

    I found a good example of VI on discussion forums that does almost the same thing, only it uses instead of the DAQ Assistant user input. The VI works including the time the program going on in a while loop. I replaced with the DAQ Assistant output (a channel) user input in the hope that it is still work.

    When I run the program in "run once" mode, it seems to work perfectly. However, in "continuous run" it measures only a very small interval, probably just the time between two samples.  I think it has something to do with the help of a while loop in combination with the DAQ Assistant. Anyone who has any suggestions how to solve this problem?

    Thank you!

    OK... first of all, you should never use the button "run continuously.  I wish that NEITHER would be to eliminate it, but told me that it is sometimes useful for debugging.  If you want your program to run over and over again, use a while loop with a stop"" button.

    If I'm reading your code correctly, you make your initial moment, and then collect data from data acquisition.  When one of the channels is "T", you stop your loop and the end time of capture.  (By the way, why you convert your table to a cluster?  Why not just index the appropriate channel in the table directly?)

    Since you want to capture the time between two consecutive pulses, you need to know when a transition has occurred... i. e when your digital line went from F (no pulse) to T (pulse start).  This will give you your forehead.  Right now, all you're doing is looking for a value T - so you have no way of knowing if you are looking for to the previous impulse again, or a new impetus.  You also burn 100% of your processor with the way you have your programme in place.

    You need a small loop delay so that your VI is not 100% of your hogs CPU time.  Given that you can live with an accuracy of 50msec, what I suggest that you use.

    See attached picture for you give an idea of how to implement.  He will probably need some refining operations, but it should point you in the right direction.

    I hope this helps.

  • IPsec VPN between two routers - mode ESP Transport and Tunnel mode

    Hi experts,

    I have this question about the Transport mode and Tunnel mode for awhile.

    Based on my understanding of 'Transport' mode is not possible because you always original "internal" private in the IP headers or IP addresses. They are always different as public IP on interfaces enabled with Crypto Card addresses. When encapsulated in the VPN tunnel, the internal IP addresses must be included or the remote VPN router won't know where to forward the packet.

    To test, I built a simple GNS3 with three routers laboratory. R1 and R3 are configured as VPN routers and the R2 must simulate Internet.

    My configs are also very basic. The R2 is routing between 1.1.1.0/24 and 2.2.2.0/24. It is defined as the gateway of R1 and R3.

    R1:

    crypto ISAKMP policy 100
    BA aes
    preshared authentication
    Group 2
    ISAKMP crypto key 123456 address 2.2.2.2
    !
    Crypto ipsec transform-set ESP_null null esp esp-sha-hmac
    !
    10 map ipsec-isakmp crypto map
    defined peer 2.2.2.2
    transformation-ESP_null game
    match address VPN

    !

    list of IP - VPN access scope
    ip permit 192.168.1.0 0.0.0.255 10.0.0.0 0.0.0.255
    !

    R3:

    crypto ISAKMP policy 100
    BA aes
    preshared authentication
    Group 2
    ISAKMP crypto key 123456 address 1.1.1.2
    !
    !
    Crypto ipsec transform-set ESP_null null esp esp-sha-hmac
    !
    10 map ipsec-isakmp crypto map
    defined peer 1.1.1.2
    transformation-ESP_null game
    match address VPN

    !

    list of IP - VPN access scope
    Licensing ip 10.0.0.0 0.0.0.255 192.168.1.0 0.0.0.255

    I configured transform-"null" value, while it will not encrypt the traffic.

    Then I tried the two 'transport' mode and mode "tunnel". I ping a host in the internal network of the R1 to another host in the internal network of the R3. I also tried 'telnet'. I also captured packets and carefully compared in both modes.

    Packets encapsulated in exactly the same way!

    It's just SPI + sequence No. + + padding

    I will attach my screenshots here for you guys to analyze it. I would be grateful for any explanation. I confused maybe just when it comes to the NAT...

    I guess my next step is to check if the two modes to make the difference when the GRE is used.

    Thank you

    Difan

    Hi Difan,

    As you point out the mode of transport is not always applicable (i.e. applicable if IP source and destination is equal to corresnpoding proxy IDs).

    A typical scenario in this mode of transport is used:

    -Encryption between two hosts

    -GRE tunnels

    -L2TP over IPsec

    Even if you set "transport mode" this does not mean that it will be used. IOS routers and I blieve also ASA will perform backup even if the mode of transport is configured but does not apply in tunnel mode.

    I can take a look at your traces to sniff, but all first can you please check if you transport mode on your ipsec security associations? "See the crypto ipsec his" exit you will show the tunnel or transport mode.

    HTH,

    Marcin

  • Traffic is failed on plain IPSec tunnel between two 892 s

    Have a weird case and you are looking for some suggestions/thougs where to dig because I have exhausted the options.

    Note: I replaced the Networkid real to a mentined below.

    Topology: a classic IPSec VPN tunnel between two 892 s of Cisco, with pre-shared key and no GRE. A 892 (branch_892) has access to the Internet using PPPoE and has three network / VLAN behind it. A VLAN is coordinated to the PPPoE internet access. Access to the other two VLAN - VL92 (100.100.200.0/24) and VL93 (100.100.100.0/24) is performed via the VPN tunnel.

    Second 892 (892_DC) has just one interface - WAN on Gigabit enabled/connected and a static route to the default GW. It doesn't have any defined interal network. If the router is strictly used to send traffic to VL92/VL93 to the domestic 892 via IPSec tunnel.

    Here's the problem: access to VL93 (100.100.100.0/24) works, however for VL92 (100.100.100.0/24) - does not work.

    Devices in VL92 I ping IP address of 892_DC through the VPN tunnel. The 892_DC router I can ping devices in VL92. However, I can't VL92 ping any device beyond the 892_DC and at the same time the packets arriving on 892_DC for VL92 are not sent through the VPN tunnel.

    I took the package trace on 892_DC using capture point/buffer to nathalie caron to VL92 packages and saw that the traffic coming to the 892_DC. I run the nathalie caron even on Branch_892, and there was not a single package.

    So... What's the problem? More interesting, I modified the way left on VL92 access list and still - no packets are sent through the tunnel.

    Any idea? Two routers config are below

    -------

    892_DC #show ru

    !

    crypto ISAKMP policy 10

    BA aes 256

    hash sha256

    preshared authentication

    Group 2

    isakmp encryption key * address 1.2.3.4

    ISAKMP crypto keepalive 10 periodicals

    !

    address of 1.2.3.4 crypto isakmp peers

    Description of-COIL-892

    !

    !

    Crypto ipsec transform-set IT-IPSec-Transform-Set esp - aes 256 sha256-esp-hmac

    Crypto ipsec df - bit clear

    !

    map IT ipsec - IPSec crypto - Crypto - map 10-isakmp

    defined peer 1.2.3.4

    disable the kilobytes of life together - the security association

    86400 seconds, life of security association set

    the transform-set IT-IPSec-Transform-Set value

    match a lists 101

    market arriere-route

    QoS before filing

    !

    interface GigabitEthernet0

    IP 10,20,30,40 255.255.255.240

    IP 1400 MTU

    IP tcp adjust-mss 1360

    automatic duplex

    automatic speed

    card crypto IT-IPSec-Crypto-map

    !

    IP route 0.0.0.0 0.0.0.0 10.20.30.41

    !

    access list 101 ip allow any 100.100.100.0 0.0.0.255 connect

    access list 101 ip allow any 100.100.200.0 0.0.0.255 connect

    -------------------------------------------------------------------------------------

    Branch_892 #sh run

    !

    crypto ISAKMP policy 10

    BA aes 256

    hash sha256

    preshared authentication

    Group 2

    isakmp encryption key * address 10,20,30,40

    ISAKMP crypto keepalive 10 periodicals

    !

    address peer isakmp crypto 10,20,30,40

    !

    !

    Crypto ipsec transform-set IT-IPSec-Transform-Set esp - aes 256 sha256-esp-hmac

    Crypto ipsec df - bit clear

    !

    map IT ipsec - IPSec crypto - Crypto - map 10-isakmp

    defined peer 10,20,30,40

    disable the kilobytes of life together - the security association

    86400 seconds, life of security association set

    the transform-set IT-IPSec-Transform-Set value

    match address 101

    market arriere-route

    QoS before filing

    !

    FastEthernet6 interface

    Description VL92

    switchport access vlan 92

    !

    interface FastEthernet7

    Description VL93

    switchport access vlan 93

    !

    interface GigabitEthernet0

    Description # to WAN #.

    no ip address

    automatic duplex

    automatic speed

    PPPoE-client dial-pool-number 1

    !

    interface Vlan1

    Description # local to #.

    IP 192.168.1.254 255.255.255.0

    IP nat inside

    IP virtual-reassembly in

    !

    interface Vlan92

    Description fa6-nexus e100/0/40

    IP 100.100.200.1 255.255.255.0

    !

    interface Vlan93

    Description fa7-nexus e100/0/38

    IP 100.100.100.1 255.255.255.0

    !

    interface Dialer0

    no ip address

    No cdp enable

    !

    interface Dialer1

    IP 1.2.3.4 255.255.255.248

    IP mtu 1454

    NAT outside IP

    IP virtual-reassembly in max-pumping 256

    encapsulation ppp

    IP tcp adjust-mss 1414

    Dialer pool 1

    Dialer-Group 1

    Authentication callin PPP chap Protocol

    PPP chap hostname ~ ~ ~

    PPP chap password =.

    No cdp enable

    card crypto IT-IPSec-Crypto-map

    !

    Dialer-list 1 ip protocol allow

    !

    access-list 101 permit ip 100.100.100.0 0.0.0.255 any

    access-list 101 permit ip 100.100.200.0 0.0.0.255 any

    !

    IP route 0.0.0.0 0.0.0.0 Dialer1

    Yes correct sounds - so another possible problem is the routing is routing 100% correct on both sides? Can you put the two sides config for review?

  • Exact differences between two images

    I need to be able to tell the difference between two images of a pastel artwork.


    The first image is of the piece, to be hung on a wall or placed on a table.


    The second is a photo of the piece after it has been moved, shaken or vibrated during which time particles were moved.


    I tried superimposing the two images and see the difference between the layers.  The images never seem to perfectly align along the lines of reference drawn in ink on the piece, and I do not understand the presentation of grayscale of the layer mode of difference.  I would like to know if anyone has any photographic photoshopic, or insightful ideas on how to capture this specific detail of change.  Another big challenge is now the images themselves to the exact distance and exposure to the room at the before and after photos, especially if they were taken in two different places on different dates.

    Best I can think of is to load into Photoshop layers >, select the two layers and go Edit > auto alignment of layers.  Then to the blending mode of the layer from the top to the difference.

    You can test so that you know what to expect by opening an image and copy the layer of BG and setting the blending mode of the layer copied the difference.  It will show as a pure black.  Now make tiny changes to the upper layer.

  • sharing between two apple ID

    How can I share contacts and calendars between two Apple ID?  Also my wife and share our music iTunes between our IDs?

    See the following topics:

    http://www.Apple.com/icloud/family-sharing/

    Family shares - Apple Support

    Implement the family sharing - Apple Support

  • How to find directions between two locations other than my current position. I finally gave up and use Google Maps.

    In the latest version of cards, there is not apparent until you find directions between two places when or is your current position. In earlier versions, we enter in two places of departure and destination. In the new version, you enter your destination into a search window, but there is no place to enter a starting location. The application assumes that your current place of residence is always your place of departure. It is a remarkable oversight by designers. Am I missing something?

    If you go to maps, you can search for a location. Once you find the place, press the route button. It is from your current location, but if you type on my position, next: you can change the location that you want the management of.

  • Can I synchronize the activity of health between two watches from Apple?

    I have two Apple - one for work, one for out watches. If I change watches in the middle of the day, the follow-up of the first watch of activity is not synchronized with the second watch. Is it possible to enable this so that the follow-up activity is specific for the whole day?

    Thank you!

    N ° it is not possible to synchronize the activity of health between two watches from Apple.

  • Syn function between two hard disks

    Is there any function of Syn in the Mac OS already has syn function between two hard disks?

    Just checking, do you mean sync?

  • Content of mail to sync between two computers

    Is it possible to synchronize the content of mail between two computers [iPhone, if possible]? Computers currently send and receive the same two e-mail accounts [not an account of @iCloud.com]. But if I receive an email, reply or remove it on a single computer, it is always also a new email unread on the other. It's a possibility, perhaps with a disc of individual cloud?

    Late 2008 MacBook Pro. El Capitan 10.11.3

    Mac Mini; El Capitan 10.11.6

    iPhone 6; IOS 9.3.5

    Thanks in advance for any help.

    Only IMAP e-mail accounts sync on devices. That's how to operate these services - nothing else is required to achieve this.

    If your email is responsible for no synchronization across all computers and devices, you must have type accounts pop connect you to these accounts via a web browser and look at your options and account services. POP is such an old system these days there is almost nobody left that enemies do not switch to IMAP.

    If all this is confusing, call your email providers and ask them to make the change on their end, then ask the information you will need to enter on your computers and your iDevices.

  • Google maps 'directions' between two points stopped working in firefox

    When using google maps to find the route between two points "Get Directions", he will just stand here loading... never finish and showing the routes between locations.
    It used to work fine a month ago. I didn't expect the update to Firefox.

    I opened the Camino to test on this browser google maps and since I did open Camino in a month or so he asked upgraded but also verified 'Flash' and asked at this level because it was outdated. I have tried re google maps "get directions" between two points on Firefox after the Flash update and it worked!
    It is a pity that so much of the web is based on Flash. Yes its cool but its also a huge pain. I wanted to just quickly answer my own post in case others are having similar problems and simply update Flash.
    See you soon

Maybe you are looking for