find and output

Questions about XML that are not covered by the other forums should go here.
Posts: 1

find and output

Sat Aug 01, 2015 1:14 pm

hi im new on oxygen xml editor using. i have a xml file contains 700+ items. and i want to find only specified label contains "GOO-*" text

input xml:

Code: Select all

  <Baslik><![CDATA[some text in here]]></Baslik>
  <UrunOnayi><![CDATA[ yok ]]></UrunOnayi>
  <Resim><![CDATA[some text in here]]></Resim>
  <Aciklama><![CDATA[<span style="font-weight: bold;">some text in here]]></Aciklama>
  <Kategori><![CDATA[El Aletleri]]></Kategori>
. . . . .

i want a file with only <barcode>label contains GOO-* text
what method is easy to use for this? and how can i do

Posts: 2453

Re: find and output

Wed Aug 05, 2015 12:02 pm


You can apply this XSL stylesheet with Saxon 6.5.5 and obtain a copy of the XML that contains only the Urun entries that have a barcode with 'GOO-', the rest are filtered out.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=""
    <xsl:output method="xml" cdata-section-elements="Baslik AltBaslik barcode UrunOnayi Resim Aciklama Kategori"/>
    <!-- Match document -->
    <xsl:template match="/">
        <xsl:apply-templates mode="copy" select="."/>
    <!-- Deep copy template -->
    <xsl:template match="node()|@*" mode="copy">
            <xsl:apply-templates mode="copy" select="@*"/>
            <xsl:apply-templates mode="copy"/>
    <!-- Handle default matching -->
    <xsl:template match="*"/>
    <xsl:template match="Urun" mode="copy">
        <xsl:if test="contains(barcode/text(), 'GOO-')">
                <xsl:apply-templates mode="copy"/>

Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

Return to “General XML Questions”

Who is online

Users browsing this forum: No registered users and 0 guests