[24717] in Perl-Users-Digest
Perl-Users Digest, Issue: 6872 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 16 18:11:04 2004
Date: Mon, 16 Aug 2004 15:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 16 Aug 2004 Volume: 10 Number: 6872
Today's topics:
Search/Replace in CSV files <doug@taperedsquare.com>
Re: Search/Replace in CSV files <noreply@gunnar.cc>
Re: Search/Replace in CSV files ctcgag@hotmail.com
Re: Search/Replace in CSV files <doug@taperedsquare.com>
Re: Search/Replace in CSV files <noreply@gunnar.cc>
Re: Search/Replace in CSV files <doug@taperedsquare.com>
Re: Search/Replace in CSV files <noreply@gunnar.cc>
Re: Search/Replace in CSV files <doug@taperedsquare.com>
Re: Search/Replace in CSV files ctcgag@hotmail.com
Re: Search/Replace in CSV files <noreply@gunnar.cc>
Sort array - subroutine help <DON'T_SEND_ME@TRIPE_TO_MY_IN.BOX>
Re: Sort array - subroutine help <mritty@gmail.com>
Re: Sort array - subroutine help <josef.moellers@fujitsu-siemens.com>
Re: Sort array - subroutine help <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Sort array - subroutine help (Anno Siegel)
Re: Sort array - subroutine help <uri.guttman@fmr.com>
Squid perl and LDAP Groups <spamtrap@Astrumtech.com>
Re: Untaint file name <Joe.Smith@inwap.com>
XML::Xerces : Schema for ignoring unknown tags ? <matrix_calling@yahoo.dot.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 16 Aug 2004 18:11:51 GMT
From: "Doug Wells" <doug@taperedsquare.com>
Subject: Search/Replace in CSV files
Message-Id: <HN6Uc.59$9W1.21589@news.uswest.net>
Hi-
I seem to be drawing a complete blank, can anyone help? I have two CSV
files. I want to look at file one and for each entry, if that entry
appears in the second file remove it from the second file. So, in the
end, i will have a new second csv file that has the first file items
removed.
Thanks
Doug
------------------------------
Date: Mon, 16 Aug 2004 20:12:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Search/Replace in CSV files
Message-Id: <2occ6eF991seU1@uni-berlin.de>
Doug Wells wrote:
> I seem to be drawing a complete blank, can anyone help? I have two
> CSV files. I want to look at file one and for each entry, if that
> entry appears in the second file remove it from the second file.
You may want to consider Tie::File for handling the second file.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 16 Aug 2004 18:27:15 GMT
From: ctcgag@hotmail.com
Subject: Re: Search/Replace in CSV files
Message-Id: <20040816142715.758$He@newsreader.com>
"Doug Wells" <doug@taperedsquare.com> wrote:
> Hi-
> I seem to be drawing a complete blank, can anyone help? I have two CSV
> files. I want to look at file one and for each entry, if that entry
> appears in the second file remove it from the second file. So, in the
> end, i will have a new second csv file that has the first file items
> removed.
Which part of this do you not know how to do? Do you not know how to
work with "CSV"[1] files? Do you not know how to work with hashes? Do you
not know how to use logic?
Xho
[1] Whatever that happens to mean in your context. Everyone's CSV seems to
be different.
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 16 Aug 2004 18:32:57 GMT
From: "Doug Wells" <doug@taperedsquare.com>
Subject: Re: Search/Replace in CSV files
Message-Id: <t57Uc.65$9W1.22610@news.uswest.net>
ctcgag@hotmail.com wrote:
> "Doug Wells" <doug@taperedsquare.com> wrote:
> > Hi-
> > I seem to be drawing a complete blank, can anyone help? I have two
> > CSV files. I want to look at file one and for each entry, if that
> > entry appears in the second file remove it from the second file.
> > So, in the end, i will have a new second csv file that has the
> > first file items removed.
>
> Which part of this do you not know how to do? Do you not know how to
> work with "CSV"[1] files? Do you not know how to work with hashes?
> Do you not know how to use logic?
>
>
> Xho
>
> [1] Whatever that happens to mean in your context. Everyone's CSV
> seems to be different.
I would guess that I'm struggling with the logic - I understand hashes,
and my CSV is simply a comma separated list of email addresses. So, i'm
not sure how to apply the logic to make happen what i want to happen.
------------------------------
Date: Mon, 16 Aug 2004 20:38:09 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Search/Replace in CSV files
Message-Id: <2ocdmvF96dptU1@uni-berlin.de>
Doug Wells wrote:
> my CSV is simply a comma separated list of email addresses.
Just email addresses, and no other data? What the h*** are you
planning to do with those addresses?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 16 Aug 2004 19:27:03 GMT
From: "Doug Wells" <doug@taperedsquare.com>
Subject: Re: Search/Replace in CSV files
Message-Id: <bU7Uc.69$9W1.25323@news.uswest.net>
Gunnar Hjalmarsson wrote:
> Doug Wells wrote:
> > my CSV is simply a comma separated list of email addresses.
>
> Just email addresses, and no other data? What the h*** are you
> planning to do with those addresses?
Since you care, it is a list of emails that I maintain for a small opt
in mailing list. And yes, it is addresses only.
------------------------------
Date: Mon, 16 Aug 2004 21:25:12 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Search/Replace in CSV files
Message-Id: <2ocgfcF8lsd2U1@uni-berlin.de>
Doug Wells wrote:
> Gunnar Hjalmarsson wrote:
>> Just email addresses, and no other data? What the h*** are you
>> planning to do with those addresses?
>
> Since you care, it is a list of emails that I maintain for a small
> opt in mailing list.
I see. Yes, I do care, and for obvious reasons I'm suspicious by
default nowadays.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 16 Aug 2004 19:47:03 GMT
From: "Doug Wells" <doug@taperedsquare.com>
Subject: Re: Search/Replace in CSV files
Message-Id: <Xa8Uc.72$9W1.26060@news.uswest.net>
Gunnar Hjalmarsson wrote:
> Doug Wells wrote:
> > Gunnar Hjalmarsson wrote:
> >> Just email addresses, and no other data? What the h*** are you
> >> planning to do with those addresses?
> >
> > Since you care, it is a list of emails that I maintain for a small
> > opt in mailing list.
>
> I see. Yes, I do care, and for obvious reasons I'm suspicious by
> default nowadays.
As I haven't used Tie::File, what advantage does that give me over just
reading the file directly into an array?
i.e. my @array = <FILENAME>;
------------------------------
Date: 16 Aug 2004 19:51:07 GMT
From: ctcgag@hotmail.com
Subject: Re: Search/Replace in CSV files
Message-Id: <20040816155107.720$Tz@newsreader.com>
"Doug Wells" <doug@taperedsquare.com> wrote:
> ctcgag@hotmail.com wrote:
>
> > "Doug Wells" <doug@taperedsquare.com> wrote:
> > > Hi-
> > > I seem to be drawing a complete blank, can anyone help? I have two
> > > CSV files. I want to look at file one and for each entry, if that
> > > entry appears in the second file remove it from the second file.
> > > So, in the end, i will have a new second csv file that has the
> > > first file items removed.
> >
> > Which part of this do you not know how to do? Do you not know how to
> > work with "CSV"[1] files? Do you not know how to work with hashes?
> > Do you not know how to use logic?
> >
> >
> > Xho
> >
> > [1] Whatever that happens to mean in your context. Everyone's CSV
> > seems to be different.
>
> I would guess that I'm struggling with the logic - I understand hashes,
> and my CSV is simply a comma separated list of email addresses. So, i'm
> not sure how to apply the logic to make happen what i want to happen.
my %h;
while ($_=parse_record_from_file1_returning_key()) {
$h{$_}=();
};
while ($_=parse_record_from_file2_into_array()) {
##Assuming it returns an arrayref, with key in first field
print_record_to_new_file($_) if not exists $h{$_->[0]}
};
This assumes that all the keys in file1 can fit in memory.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 16 Aug 2004 21:55:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Search/Replace in CSV files
Message-Id: <2oci7sF8sq09U1@uni-berlin.de>
Doug Wells wrote:
> Gunnar Hjalmarsson wrote:
>> Doug Wells wrote:
>>> I seem to be drawing a complete blank, can anyone help? I have two
>>> CSV files. I want to look at file one and for each entry, if that
>>> entry appears in the second file remove it from the second file.
>>
>> You may want to consider Tie::File for handling the second file.
>
> As I haven't used Tie::File, what advantage does that give me over just
> reading the file directly into an array?
>
> i.e. my @array = <FILENAME>;
Well, when suggesting that, I was assuming that the file consisted of
one record ("entry") per line, and that respective record contained
comma separated fields...
The difference would be that changing or deleting an array element
would instantly be reflected in the file.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 16 Aug 2004 14:55:19 +0100
From: "Nath" <DON'T_SEND_ME@TRIPE_TO_MY_IN.BOX>
Subject: Sort array - subroutine help
Message-Id: <4120bccd$0$27968$afc38c87@news.ukonline.co.uk>
I have an array of arrays:
my $output_aln_types = [
['Clustal', '.aln'],
['NEXUS', ['.nex', '.nexus']],
['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
'.nt', '.aa' ] ],
['MEGA', [ '.meg', '.mega' ]],
['User Defined', '*.*'],
];
I want to sort it so that it is alphabetical, BUT with 'NEXUS' first, and
'User Defined' last. the sort should return the following array of arrays:
my $output_aln_types = [
['NEXUS', ['.nex', '.nexus']],
['Clustal', '.aln'],
['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
'.nt', '.aa' ] ],
['MEGA', [ '.meg', '.mega' ]],
['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
['User Defined', '*.*'],
];
i can use the following subroutine to sort alphabetically, but don't know
how to place the 2 conditions of 'NEXUS' first, and 'User Defined' last:
@$output_aln_types = sort { $a->[0] cmp $b->[0] } @$output_aln_types;
Thanks
Nathan
------------------------------
Date: Mon, 16 Aug 2004 10:12:31 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Sort array - subroutine help
Message-Id: <20040816100806.C2996@barbara.cs.rpi.edu>
On Mon, 16 Aug 2004, Nath wrote:
> I have an array of arrays:
>
> my $output_aln_types = [
> ['Clustal', '.aln'],
> ['NEXUS', ['.nex', '.nexus']],
> ['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
> ['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
> '.nt', '.aa' ] ],
> ['MEGA', [ '.meg', '.mega' ]],
> ['User Defined', '*.*'],
> ];
>
> I want to sort it so that it is alphabetical, BUT with 'NEXUS' first, and
> 'User Defined' last. the sort should return the following array of arrays:
>
> my $output_aln_types = [
> ['NEXUS', ['.nex', '.nexus']],
> ['Clustal', '.aln'],
> ['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
> '.nt', '.aa' ] ],
> ['MEGA', [ '.meg', '.mega' ]],
> ['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
> ['User Defined', '*.*'],
> ];
>
> i can use the following subroutine to sort alphabetically, but don't know
> how to place the 2 conditions of 'NEXUS' first, and 'User Defined' last:
>
> @$output_aln_types = sort { $a->[0] cmp $b->[0] } @$output_aln_types;
>
untested:
sub mySort {
return -1 if $a->[0] eq 'NEXUS' or $b->[0] eq 'User Defined';
return 1 if $b->[0] eq 'NEXUS' or $a->[0] eq 'User Defined';
$a->[0] cmp $b->[0];
}
@$output_aln_types = sort mySort @$output_aln_types;
Paul Lalli
------------------------------
Date: Mon, 16 Aug 2004 16:18:07 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Sort array - subroutine help
Message-Id: <cfqfev$b7j$1@nntp.fujitsu-siemens.com>
Nath wrote:
> I have an array of arrays:
>=20
> my $output_aln_types =3D [
> ['Clustal', '.aln'],
> ['NEXUS', ['.nex', '.nexus']],
> ['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph=
' ]],
> ['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
> '.nt', '.aa' ] ],
> ['MEGA', [ '.meg', '.mega' ]],
> ['User Defined', '*.*'],
> ];
>=20
> @$output_aln_types =3D sort { $a->[0] cmp $b->[0] } @$output_aln_types;=
How about:
@$output_aln_types =3D sort { $a->[0] eq 'NEXUS' ? -1 : $b->[0] eq 'NEXUS=
'
? 1 : $a->[0] eq 'User Defined' ? 1 : $b->[0] eq 'User Defined' ? -1
: $a->[0] cmp $b->[0] } @$output_aln_types;
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Mon, 16 Aug 2004 16:15:06 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Sort array - subroutine help
Message-Id: <Xns9547A5C99C3ADelhber1lidotechnet@62.89.127.66>
"Nath" <DON'T_SEND_ME@TRIPE_TO_MY_IN.BOX> wrote:
> I have an array of arrays:
>
> my $output_aln_types = [
> ['Clustal', '.aln'],
> ['NEXUS', ['.nex', '.nexus']],
> ['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy',
> '.ph' ]], ['FASTA', [ '.fas', '.fasta', '.fast', '.seq',
> '.fa', '.fsa',
> '.nt', '.aa' ] ],
> ['MEGA', [ '.meg', '.mega' ]],
> ['User Defined', '*.*'],
>];
>
> I want to sort it so that it is alphabetical, BUT with 'NEXUS'
> first, and 'User Defined' last.
[...]
Simply remove the 'NEXUS' and 'User Defined' arrays from
$output_aln_types, sort, then put the removed arrays in their desired
places after sorting (using push() and unshift(), for example).
--
Cheers,
Bernard
------------------------------
Date: 16 Aug 2004 16:02:04 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Sort array - subroutine help
Message-Id: <cfqlps$2nu$1@mamenchi.zrz.TU-Berlin.DE>
Nath <DON'T_SEND_ME@TRIPE_TO_MY_IN.BOX> wrote in comp.lang.perl.misc:
> I have an array of arrays:
>
> my $output_aln_types = [
> ['Clustal', '.aln'],
> ['NEXUS', ['.nex', '.nexus']],
> ['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
> ['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
> '.nt', '.aa' ] ],
> ['MEGA', [ '.meg', '.mega' ]],
> ['User Defined', '*.*'],
> ];
>
> I want to sort it so that it is alphabetical, BUT with 'NEXUS' first, and
> 'User Defined' last. the sort should return the following array of arrays:
>
> my $output_aln_types = [
> ['NEXUS', ['.nex', '.nexus']],
> ['Clustal', '.aln'],
> ['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
> '.nt', '.aa' ] ],
> ['MEGA', [ '.meg', '.mega' ]],
> ['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
> ['User Defined', '*.*'],
> ];
>
> i can use the following subroutine to sort alphabetically, but don't know
> how to place the 2 conditions of 'NEXUS' first, and 'User Defined' last:
>
> @$output_aln_types = sort { $a->[0] cmp $b->[0] } @$output_aln_types;
Lots of ways. You could sort using a specific comparison routine
that sorts "NEXUS" first and "User Defined" last:
@$output_aln_types = sort compare @$output_aln_types;
sub compare {
my ( $x, $y) = ( $a->[ 0], $b->[ 0]);
return -1 if $x eq 'NEXUS';
return 1 if $y eq 'NEXUS';
return 1 if $x eq 'User Defined';
return -1 if $y eq 'User Defined';
$x cmp $y;
}
Or you could exclude the special elements from the list and treat them
separately:
my ( $nexus) = grep $_->[ 0] eq 'NEXUS', @$output_aln_types;
my ( $user_defined) = grep $_->[ 0] eq 'User Defined', @$output_aln_types;
@$output_aln_types = sort { $a->[0] cmp $b->[0] }
grep { $_->[ 0] ne 'NEXUS' and $_->[ 0] ne 'User Defined' }
@$output_aln_types;
unshift @$output_aln_types, $nexus;
push @$output_aln_types, $user_defined;
...or sort the list no matter what, and move the special elements to
their places later:
@$output_aln_types = sort { $a->[0] cmp $b->[0] } @$output_aln_types;
my ( $i) = grep $output_aln_types->[ $_]->[ 0] eq 'NEXUS',
0 .. $#$output_aln_types;
unshift @$output_aln_types, splice @$output_aln_types, $i, 1;
( $i) = grep $output_aln_types->[ $_]->[ 0] eq 'User Defined',
0 .. $#$output_aln_types;
push @$output_aln_types, splice @$output_aln_types, $i, 1;
The last two solutions rely on the existence of "NEXUS" and "User Defined"
in the original list. If that can't be guaranteed, it should be checked.
The first solution doesn't care if one or both are missing.
Anno
------------------------------
Date: Mon, 16 Aug 2004 12:42:53 -0400
From: Uri Guttman <uri.guttman@fmr.com>
Subject: Re: Sort array - subroutine help
Message-Id: <lid61ruj8y.fsf@fmr.com>
>>>>> "N" == Nath <DON'T_SEND_ME@TRIPE_TO_MY_IN.BOX> writes:
N> I have an array of arrays:
N> my $output_aln_types = [
N> ['Clustal', '.aln'],
N> ['NEXUS', ['.nex', '.nexus']],
N> ['Phylip', [ '.phy', '.phylip', '.phlp', '.phyl', '.phy', '.ph' ]],
N> ['FASTA', [ '.fas', '.fasta', '.fast', '.seq', '.fa', '.fsa',
N> '.nt', '.aa' ] ],
N> ['MEGA', [ '.meg', '.mega' ]],
N> ['User Defined', '*.*'],
N> ];
N> I want to sort it so that it is alphabetical, BUT with 'NEXUS' first, and
N> 'User Defined' last. the sort should return the following array of arrays:
N> @$output_aln_types = sort { $a->[0] cmp $b->[0] } @$output_aln_types;
<untested>
use Sort::Maker ;
my $sorter = make_sorter( style => 'GRT', string => q{
$_->[0] eq 'NEXUS' ? '' :
$_->[0] eq 'User Defined' ? "\xff" :
$_->[0] } ) ;
my @sorted = $sorter->(@unsorted) ;
note that '' (used as the key for NEXUS) will sort before all regular
strings). and 0xff (used as the key for 'User Defined') will sort after
all regular. otherwise the regular string key is used.
this will also be much faster (if the input array size is large enough)
than the common sort block.
and it is much clearer than the other solutions which have redundant
code and you have to know when to return 1 or -1. the tradeoff is a
module and knowing how to create key values that sort before/after all
normal keys.
uri
------------------------------
Date: Mon, 16 Aug 2004 14:28:33 -0400
From: "BerkHolz, Steven" <spamtrap@Astrumtech.com>
Subject: Squid perl and LDAP Groups
Message-Id: <2occmdF96hjvU1@uni-berlin.de>
I have looked all over the net and have found very many references to LDAP
Group lookup for Squid-cache, but have been unable to get any to work.
Does anyone have a working perl script that accepts a name and password
(from Squid Proxy Request) and can look in the MemberOf attribute and match
a group in MS AD 2003?
If so, I would greatly appreciate a copy.
I think it should work like:
perl ldapperlscript.pl "cn=TheGroupIamCheckingFor,dc=MyDomain,dc=com" then
std-in would submit proxyusername (space) proxypassword.
The script verify the auth of proxyisername via the password, then lookup
the attribute of "MemberOf" looking for the first arg sent to the script.
As far as I know, Squid looks of output of "OK", but I may be mistaken.
--
Steven BerkHolz
Send to Domain TESCOGroup dot com, username SB
Note: you may also want to know that you should never send mail to:
blacklist-my-ip@admins.ws
info@dautrap.uceprotect.net
listme@sorbs.net
spamtrap@sandes.dk
spamtrap@stop.mail-abuse.org
spamtrap@frankenbiker.de
spamtrap@blars.org
--
Steven BerkHolz
Send to Domain TESCOGroup dot com, username SB
Note: you may also want to know that you should never send mail to:
blacklist-my-ip@admins.ws
info@dautrap.uceprotect.net
listme@sorbs.net
spamtrap@sandes.dk
spamtrap@stop.mail-abuse.org
spamtrap@frankenbiker.de
spamtrap@blars.org
------------------------------
Date: Mon, 16 Aug 2004 19:49:51 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Untaint file name
Message-Id: <zd8Uc.264172$a24.82660@attbi_s03>
Gunnar Hjalmarsson wrote:
> Something like this should -
> typically - work on both *nix and Windows:
>
> if ( $PATH =~ /^([-\w\/\\.: ]+)$/ ) {...
That makes sure the filename does not contain shell metacharacters,
but does not guard against malicious input. A separate check should
be made to watch out for things like "../../../etc/passwd".
-Joe
------------------------------
Date: Mon, 16 Aug 2004 23:35:29 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: XML::Xerces : Schema for ignoring unknown tags ?
Message-Id: <EO6Uc.51$bW.26@news.oracle.com>
Hi,
I posted this on comp.text.xml, but could not resolve the issue. I am
posting this here in the hope that this is specific to XML::Xerces :
>>
>> Abhinav wrote: (In comp.text.xml)
>>
>>
>>
>
>>>>I have an xml which contains the following
>>>>
>>>><a>
>>>> <!-- aa Is what I am interested in -->
>>>> <aa>
>>>> </aa>
>>>>
>>>> <bb></bb>
>>>> <cc></cc>
>>>>
>>>></a>
>>>>
>>>>Here, my application requires that <a> (The root element) *must* contain
>>>><aa> tag.
>>>>
>>>>However, tags such as <bb>, <cc>, or anything else might exist - they
>>>>are optional, and I do not know which of them (if at all) will be present.
>>>>
>>>>How do I write the schema for it ?
>>>>
>>>>Using all requires that I know which tags might appear ..
>>>>
>>>>Using any doesnt allow me to check the presence of the specific tag <aa>
>>>>
>>>>Any pointers on how to achieve this ?
>
>>
>>
>> It is simple, use a sequence with one defined element and xs:any:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xs:schema
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> version="1.0">
>>
>> <xs:element name="a">
>> <xs:complexType>
>> <xs:sequence>
>> <xs:element name="aa" type="xs:string" />
>> <xs:any processContents="lax" maxOccurs="unbounded" />
>> </xs:sequence>
>> </xs:complexType>
>> </xs:element>
>>
>> </xs:schema>
>>
>Thanks .. That worked ..
>
>However, If I want to ignore elements both *before* and *after* <aa> ?
>adding another <xs:any> before <xs:element name="aa"> does not work.
>XML::Xerces gives the error :
>
>MESSAGE: Not enough elements to match content model : '((,aa),)'
>Any pointers appreciated!
Is it actually possible (In XML in general, and XML::Xerces in particular)
to check for an arbitrary no. of tags before and after ther required tags?
TIA
--
Abhinav
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6872
***************************************