Page 1 of 1

Splitting an XML file into multiple XML files

Posted: Thu Aug 04, 2022 6:44 pm
by jmmarshalljb
Good morning,
I am looking to split a large XML file in multiple XML files based on the "row _id" element. So for each section starting with <row _id="row......." a separate XML or text would be created. I just got Oxygen XML editor and am a novice at this. It looks like I can do a split, but I cannot figure how to apply the split to the file that I have.
A step-by-step list of instructions would be the most helpful, but I would appreciate any guidance at this point.
Below my signature, I have pasted a sample one of the "row _id" elements to give an idea of what the original filet looks like. For some reason, I could not attach a file to this posting.
Regards,
jmmarshalljb

Code: Select all

<response><row><row _id="row-cf53~pid2-e9iy" _uuid="00000000-0000-0000-C8B6-74603B44B5EB" _position="0" _address="https://priv-data.ojp.usdoj.gov/resource/_6h3w-ci9p/row-cf53~pid2-e9iy"><interventionpublic_id>6324</interventionpublic_id><intervention_id>39</intervention_id><title>Program Profile: San Francisco (Calif.) Behavioral Health Court</title><evidence_rating>Promising - One study</evidence_rating><topics>Courts, Crime &amp; Crime Prevention</topics><summary>The court aims to connect defendants with serious mental illness to community treatment services, to find dispositions to their criminal charges that take into account their mental illness, and to decrease the chances they return to the criminal justice system. The program is rated Promising. The study showed participants were statistically significantly less likely to be charged with a new offense and had a longer time without a new violent charge compared with the comparison group.</summary><randomized_controlled_trial>None</randomized_controlled_trial><program_description>Program Goals
The San Francisco Behavioral Health Court (BHC) is a mental health court established in early 2003 in response to the increasing numbers of mentally ill defendants cycling through the jails and courts. The court aims to intensely monitor a subset of mentally ill offenders whose criminal behavior is directly linked to their mental illness. The mission of the BHC is to:

Connect criminal defendants who have serious mental illness to treatment services
Find disposition to their criminal charges that take mental illness into consideration
Ensure public safety by decreasing recidivism through appropriate mental health treatment and intensive supervision

Target Population/Eligibility
Participation in BHC is voluntary, and in many instances, the defendant does not have to enter a guilty plea to criminal charges in order to enter the program. To qualify for participation in the BHC, defendants must be diagnosed as having an axis I mental disorder according to the Diagnostic and Statistical Manual of Mental Disorders, Fourth Edition (DSM-IV) or, in some circumstances, developmental disabilities. Defendants must also be amenable to treatment in the community mental health system. The gravity of the criminal charges against a defendant is also considered, although BHC does accept a substantial proportion of defendants who are charged with felony offenses.
Services Provided
The BHC provides services to participants through a continuum of care, beginning with in-jail services, transitional care prior to release, and early release into the community. The court has adopted several practices for treating mental ill offenders, including Forensic Assertive Community Treatment, Illness Management and Recovery, Trauma Informed Care, Integrated Dual Diagnosis Treatment, Dialectical Behavior Therapy, and the Supported Employment Program. The BHC has also adopted the Women"s Integrated Skills and Health (or WISH) Project, which diverts in-custody female offenders with co-occurring disorders to appropriate community mental health treatment services. The BHC is one of the only mental health courts in the country to develop gender specific treatment.
Key Personnel
The BHC involves collaboration between the Superior Court, the Public Defender"s Office, the District Attorney"s Office, the Sheriff"s Department, the Haight Ashbury Free Clinic"s Jail Psychiatric Services, the University of California, San Francisco"s Citywide Case Management, and the city"s Department of Public Health. The judge and lawyers work closely with mental health providers, who provide intensive case management that centers around the client"s diagnosis and psychosocial needs rather than his or her criminal charges. The court anticipates that relapses may occur, and it emphasizes positive reinforcement for successes rather than sanctions for failure. Participants who successfully maintain a sustained period of stability "graduate" from the mental health court.</program_description><program_description_html>&lt;h3>Program Goals&lt;/h3>
&lt;p>The San Francisco Behavioral Health Court (BHC) is a mental health court established in early 2003 in response to the increasing numbers of mentally ill defendants cycling through the jails and courts. The court aims to intensely monitor a subset of mentally ill offenders whose criminal behavior is directly linked to their mental illness. The mission of the BHC is to:&lt;/p>
&lt;ul>
&lt;li>Connect criminal defendants who have serious mental illness to treatment services&lt;/li>
&lt;li>Find disposition to their criminal charges that take mental illness into consideration&lt;/li>
&lt;li>Ensure public safety by decreasing recidivism through appropriate mental health treatment and intensive supervision&lt;/li>
&lt;/ul>
&lt;h3>Target Population/Eligibility&lt;/h3>
&lt;p>Participation in BHC is voluntary, and in many instances, the defendant does not have to enter a guilty plea to criminal charges in order to enter the program. To qualify for participation in the BHC, defendants must be diagnosed as having an axis I mental disorder according to the Diagnostic and Statistical Manual of Mental Disorders, Fourth Edition (DSM&amp;ndash;IV) or, in some circumstances, developmental disabilities. Defendants must also be amenable to treatment in the community mental health system. The gravity of the criminal charges against a defendant is also considered, although BHC does accept a substantial proportion of defendants who are charged with felony offenses.&lt;/p>
&lt;h3>Services Provided&lt;/h3>
&lt;p>The BHC provides services to participants through a continuum of care, beginning with in-jail services, transitional care prior to release, and early release into the community. The court has adopted several practices for treating mental ill offenders, including Forensic Assertive Community Treatment, Illness Management and Recovery, Trauma Informed Care, Integrated Dual Diagnosis Treatment, Dialectical Behavior Therapy, and the Supported Employment Program. The BHC has also adopted the Women&amp;rsquo;s Integrated Skills and Health (or WISH) Project, which diverts in-custody female offenders with co-occurring disorders to appropriate community mental health treatment services. The BHC is one of the only mental health courts in the country to develop gender specific treatment.&lt;/p>
&lt;h3>Key Personnel&lt;/h3>
&lt;p>The BHC involves collaboration between the Superior Court, the Public Defender&amp;rsquo;s Office, the District Attorney&amp;rsquo;s Office, the Sheriff&amp;rsquo;s Department, the Haight Ashbury Free Clinic&amp;rsquo;s Jail Psychiatric Services, the University of California, San Francisco&amp;rsquo;s Citywide Case Management, and the city&amp;rsquo;s Department of Public Health. The judge and lawyers work closely with mental health providers, who provide intensive case management that centers around the client&amp;rsquo;s diagnosis and psychosocial needs rather than his or her criminal charges. The court anticipates that relapses may occur, and it emphasizes positive reinforcement for successes rather than sanctions for failure. Participants who successfully maintain a sustained period of stability &amp;ldquo;graduate&amp;rdquo; from the mental health court.&lt;/p></program_description_html><evaluation_methodology>Study 1
McNiel and Binder (2007) used a retrospective observational design with nonrandom assignment to compare the occurrence of new criminal charges to people who entered the San Francisco Behavioral Health Court (BHC) after arrest to other adults with mental disorders who were booked into an urban county jail after arrest. The primary research objective was to determine whether participation in BHC was associated with a longer time without recidivism compared with treatment as usual.
A total of 8,325 individuals 18 years of age or older who were diagnosed as having a mental disorder entered the San Francisco jail during the study period. Of these, the study looked at 170 individuals for whom complete data was available, including at least 6 months of follow-up. The comparison group consisted of 8,067 persons who did not participate in the BHC and received treatment as usual. Data was obtained from the administrative database associated with the San Francisco county court and jail systems.
For the treatment group, the baseline period was defined as the 12 months before the date of entry to the program. For the comparison group, the baseline period was defined as the 12 months before the date of the first arrest (the index arrest) that occurred between Jan. 14, 2003, and Nov. 19, 2004. Follow-up data for both groups were obtained through May 27, 2005.
The outcome variable was recidivism, which was measured as rearrest for two categories of new charges: any offense and violent crimes. The study used a propensity weighting procedure to create a sample of treatment cases comparable to those in the control group to account for differences in baseline characteristics between the treatment and control group. The statistical approach involved time-to-event analysis (i.e., survival analysis) using the Cox proportional hazards model. The primary survival analyses used intent-to-treat analyses to compare those in the mental health court group with those in the treatment-as-usual group without distinguishing whether individuals graduated from the mental health court program or not. The survival analyses also included comparing recidivism after graduation (for those who graduated from the program) with recidivism in the treatment-as-usual group to determine whether the changes associated with mental health court participation were maintained after successful completion of the program.</evaluation_methodology><evaluation_methodology_html>&lt;h3>Study 1&lt;/h3>
&lt;p>McNiel and Binder (2007) used a retrospective observational design with nonrandom assignment to compare the occurrence of new criminal charges to people who entered the San Francisco Behavioral Health Court (BHC) after arrest to other adults with mental disorders who were booked into an urban county jail after arrest. The primary research objective was to determine whether participation in BHC was associated with a longer time without recidivism compared with treatment as usual.&lt;/p>
&lt;p>A total of 8,325 individuals 18 years of age or older who were diagnosed as having a mental disorder entered the San Francisco jail during the study period. Of these, the study looked at 170 individuals for whom complete data was available, including at least 6 months of follow-up. The comparison group consisted of 8,067 persons who did not participate in the BHC and received treatment as usual. Data was obtained from the administrative database associated with the San Francisco county court and jail systems.&lt;/p>
&lt;p>For the treatment group, the baseline period was defined as the 12 months before the date of entry to the program. For the comparison group, the baseline period was defined as the 12 months before the date of the first arrest (the index arrest) that occurred between Jan. 14, 2003, and Nov. 19, 2004. Follow-up data for both groups were obtained through May 27, 2005.&lt;/p>
&lt;p>The outcome variable was recidivism, which was measured as rearrest for two categories of new charges: any offense and violent crimes. The study used a propensity weighting procedure to create a sample of treatment cases comparable to those in the control group to account for differences in baseline characteristics between the treatment and control group. The statistical approach involved time-to-event analysis (i.e., survival analysis) using the Cox proportional hazards model. The primary survival analyses used intent-to-treat analyses to compare those in the mental health court group with those in the treatment-as-usual group without distinguishing whether individuals graduated from the mental health court program or not. The survival analyses also included comparing recidivism after graduation (for those who graduated from the program) with recidivism in the treatment-as-usual group to determine whether the changes associated with mental health court participation were maintained after successful completion of the program.&lt;/p></evaluation_methodology_html><evaluation_outcomes>Study 1
New Charges
McNiel and Binder (2007) found that at 18 months, participants in the San Francisco Behavioral Health Court (BHC) were 26 percent less likely to be charged with a new offense, compared with the treatment-as-usual group. This result was statistically significant.
Time to New Charges
The BHC participants had a statistically significantly longer length of time until incurring a new charge than the comparison group at the 18-month follow-up.
New Violent Charges
At 18 months, participants in BHC were 55 percent less likely to be charged with a new violent offense, compared with the treatment-as-usual group. This result was statistically significant.
Time to Violent Charges
The BHC participants had a statistically significantly longer length of time until incurring a new violent charge than the comparison group at the 18-month follow-up.</evaluation_outcomes><evaluation_outcomes_html>&lt;h3>Study 1&lt;/h3>
&lt;h3>New Charges&lt;/h3>
&lt;p>McNiel and Binder (2007) found that at 18 months, participants in the San Francisco Behavioral Health Court (BHC) were 26 percent less likely to be charged with a new offense, compared with the treatment-as-usual group. This result was statistically significant.&lt;/p>
&lt;h3>Time to New Charges&lt;/h3>
&lt;p>The BHC participants had a statistically significantly longer length of time until incurring a new charge than the comparison group at the 18-month follow-up.&lt;/p>
&lt;h3>New Violent Charges&lt;/h3>
&lt;p>At 18 months, participants in BHC were 55 percent less likely to be charged with a new violent offense, compared with the treatment-as-usual group. This result was statistically significant.&lt;/p>
&lt;h3>Time to Violent Charges&lt;/h3>
&lt;p>The BHC participants had a statistically significantly longer length of time until incurring a new violent charge than the comparison group at the 18-month follow-up.&lt;/p></evaluation_outcomes_html><cost>A 2009 cost–benefit analysis of the Behavioral Health Court (BHC) found that in the third year after participants entered the program, criminal justice and mental health treatment savings completely offset annual BHC operating costs and resulted in a net benefit of $277,000. Using an average annual BHC caseload of 206 clients, the study authors estimated that operating costs per person were approximately $12,101 (Lindberg 2009).</cost><evidence_base>&lt;strong>Study 1&lt;/strong>&lt;br>&lt;p>McNiel, Dale E., and Renee L. Binder. 2007. &amp;ldquo;Effectiveness of a Mental Health Court in Reducing Criminal Recidivism and Violence.&amp;rdquo; &lt;em>American Journal of Psychiatry&lt;/em> 164(9):1395&amp;ndash;1403.&lt;/p></evidence_base><additional_references>&lt;p>County of San Francisco, Superior Court of California. 2010. &amp;ldquo;Behavioral Health Court.&amp;rdquo; Accessed Dec. 20, 2010.&lt;/p>&lt;br>&lt;br />Lindberg, Arley. 2009. &lt;em>Findings From Examining Program Costs and Outcomes of San Francisco&amp;rsquo;s Behavioral Health Court.&lt;/em> San Francisco, Calif.: San Francisco Collaborative Courts, Administrative Office of the Courts, Collaborative Justice Unit.&lt;br></additional_references><age>18+</age><ages>[{}]</ages><gender>Male, Female</gender><ethnicity>N/A</ethnicity><deliverysetting>Other Community Setting, Courts</deliverysetting><program_type>Alternatives to Incarceration, Diversion, Mental Health Court</program_type><geography>Urban</geography><targeted_population>Mentally Ill Offenders</targeted_population><current_program_status>Active</current_program_status><othersite>N/A</othersite><contacts>&lt;p>&lt;strong>&lt;label id="Program Director">Program Director:&lt;/label>&lt;/strong>&lt;br> Lisa Lightman&lt;br>Director&lt;br />Superior Court of California, County of San Francisco&lt;br />400 McAllister St.&lt;br />San Francisco CA 94102&lt;br />Phone: 415.551.3983&lt;br />Fax: 415.551.5701&lt;br />&lt;a href="http://www.sfsuperiorcourt.org/index.aspx?page=88" target=new aria-labelledby="Program Director">Website&lt;/a>&lt;br />&lt;a href="mailto:llightman@sftc.org" target=new aria-labelledby="Program Director">Email&lt;/a>&lt;/p>&lt;p>&lt;strong>&lt;label id="Researcher">Researcher:&lt;/label>&lt;/strong>&lt;br> Dale McNiel&lt;br>Professor of Clinical Psychology&lt;br />Langley Porter Psychiatric Institute, University of California&lt;br />401 Parnassus Ave.&lt;br />San Francisco CA 94143&lt;br />&lt;a href="mailto:dalem@lppi.uscsf.edu" target=new aria-labelledby="Researcher">Email&lt;/a>&lt;/p></contacts><related_practices>&lt;a href=PracticeDetails.aspx?ID=34>&lt;b>Adult Mental Health Courts&lt;/b>&lt;/a>&lt;br>Specialized, treatment-oriented, problem-solving courts that divert mentally ill offenders away from the criminal justice system and into court-mandated, community-based treatment programs in order to reduce recidivism and decrease the amount of contact that mentally ill individuals have with the criminal justice system. The practice is rated Promising for reducing recidivism, but rated No Effects on measures of clinical outcomes.&lt;br>&lt;br>&lt;b>Evidence Ratings for Outcomes:&lt;/b>&lt;br>&lt;table>&lt;tr>&lt;td valign=top>&lt;img src="images\promising_multi_small.jpg" alt="Promising - More than one Meta-Analysis"> &lt;/td>&lt;td>Crime &amp; Delinquency - Multiple crime/offense types&lt;/td>&lt;/tr>&lt;tr>&lt;td valign=top>&lt;img src="images\ineffective_small.jpg" alt="No Effects - One Meta-Analysis"> &lt;/td>&lt;td>Mental Health &amp; Behavioral Health - Multiple mental health/behavioral health outcomes&lt;/td>&lt;/tr>&lt;/table></related_practices><datepostedpublic>2011-06-08T10:40:33</datepostedpublic><other_information>McNiel and Binder (2007) reported that statistically significant positive outcomes were also associated with completion and graduation from the Behavioral Health Court (BHC). For example, BHC graduates continued to show a longer time before incurring any new charges after graduating, compared with individuals who received treatment as usual. At 18 months, BHC graduates were 39 percent less likely to have been charged with a new offense, compared with the treatment-as-usual group and a longer time before incurring any new violent charges after graduating from the program. In addition, BHC graduates were 54 percent less likely to have been charged with a new violent offense, compared with the treatment-as-usual group.</other_information><topics_mpg>|Crime &amp; Crime Prevention|Courts|Mental Health &amp; Crime|Sentencing &amp; Sanctions|Specialized &amp; Problem Solving Courts|Alternatives to Detention &amp; Incarceration|Mental Health Courts|</topics_mpg><factors>N/A</factors><topic_ids>~1~3~18~48~49~220~241~</topic_ids><factor_ids>N/A</factor_ids><replicated>0</replicated><semaphore_terms>[{"id":"29128c54-945f-5aee-8f7e-58c4655d3687","term":"Courts"},{"id":"725b3be6-8b5a-42ca-8f0e-8d343fe40660","term":"Mental health"},{"id":"788df909-b671-455c-b116-d798faaa966f","term":"Sentencing and sanctions "},{"id":"7ce53ad6-7f5d-57bb-bb07-b9e1b36847a1","term":"Alternatives to incarceration "},{"id":"ab672cca-4677-5f9e-9b65-9d8d0a6f47e4","term":"Crime"},{"id":"cac5b0e6-ada3-526f-bd9e-5264fe3ef0ca","term":"Mental Health Courts"},{"id":"fe72d9eb-4b44-45f3-b550-bbe4497ec09b","term":"Problem-solving courts"}]</semaphore_terms></row>

Re: Splitting an XML file into multiple XML files

Posted: Fri Aug 05, 2022 7:50 am
by Radu
Hi,

There is a standard named XSLT which allows processing XML documents, even splitting them in multiple documents.
There are various XSLT courses available online:
https://blog.oxygenxml.com/topics/xslt_training.html
I will give you a small example:
1) I open in Oxygen a "test.xsl" file XSLT stylesheet with the contents:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">
    <xsl:template match="/">
        <xsl:for-each select="//row[@_id]">
            <xsl:result-document href="{@_id}.xml">
                <xsl:copy-of select="."/>
            </xsl:result-document>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>
2) I open in Oxygen a "test.xml" file with the contents:

Code: Select all

<response>
    <rows>
        <row _id="id1">
            test1
        </row>
        <row _id="id2">
            test1
        </row>
    </rows>
</response>
On the Oxygen toolbar there is a "Configure Transformation Scenarios" toolbar button, I click it, I press "New" to create a new transformation scenario of type "XML with XSLT":
https://www.oxygenxml.com/doc/versions/ ... -xslt.html
In the "XSL URL" field I set a reference to the "test.xsl" stylesheet.
I use my new transformation scenario to transform the XML with the XSLT, next to the "test.xml" document there now should be two files named "id1.xml" and "id2.xml" containing the contents of each row element.
Hope this helps.

Regards,
Radu