⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parser.html

📁 SVG 是一种广泛使用的矢量图格式
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<head><!-- Generated by perlmod2www.pl --><title>Parser documentation.</title></head><body bgcolor="white"><HR><H4>SVG</H4><H3>Parser</H3><A NAME="TOP"></A><TABLE BORDER="1" WIDTH="100%"><TR><TD><A HREF="#SUMMARY">Summary</A></TD><TD><A HREF="#libs">Included libraries</A></TD><TD><A HREF="#vardefs">Package variables</A></TD><TD><A HREF="#SYNOPSIS">Synopsis</A></TD><TD><A HREF="#DESCRIPTION">Description</A></TD><TD><A HREF="#General">General documentation</A></TD><TD><A HREF="#Methods">Methods</A></TD></TR></TABLE><HR><TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"><TR><TD BGCOLOR="#ffae84"><B>Summary</B></TD></TR></TABLE><TABLE BORDER="0" WIDTH="100%"><TR><TD><pre><B>SVG::Parser</B> - XML Parser for SVG documents<BR></pre></TD></TR></TABLE><A NAME="vardefs"></A><TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"><TR BGCOLOR="#ffae84"><TD><B>Package variables</B></TD><TD ALIGN="RIGHT"><A HREF="#TOP">top</A></TD></TR></TABLE><TABLE BORDER="0" WIDTH="100%"><TR BGCOLOR="#ffd39b"><TD COLSPAN="2"><B>Globals (from <FONT COLOR="BLUE">use vars</FONT> definitions)</B></TD></TR><TR><TD COLSPAN="2"><font color="#1f32ff">$VERSION</font> = <font color="#007400">"0.97"</font></TD></TR></TABLE><TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"><TR BGCOLOR="#ffae84"><TD WIDTH="150"><B>Included modules</B></TD><TD ALIGN="RIGHT"><A HREF="#TOP">top</A></TD></TR></TABLE><TABLE BORDER="0"><TR><TD COLSPAN="2"><b><font color="#0000ff">strict</font></b></TD></TR></TABLE><A NAME="libs"></A><TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"><TR BGCOLOR="#ffae84"><TD><B>Inherit</B></TD><TD ALIGN="RIGHT"><A HREF="#TOP">top</A></TD></TR></TABLE><TABLE BORDER="0"><TR><TD><b><font color="#0000ff"><a href="Parser/Expat.html">SVG::Parser::Expat</a></font></b> <b><font color="#0000ff"><a href="Parser/SAX.html">SVG::Parser::SAX</a></font></b> </TD></TR></TABLE><A NAME="SYNOPSIS"></A><TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"><TR BGCOLOR="#ffae84"><TD><B>Synopsis</B></TD><TD ALIGN="RIGHT"><A HREF="#TOP">top</A></TD></TR></TABLE><TABLE BORDER="0"><TR><TD COLSPAN="2"><pre>  #!/usr/bin/perl -w<BR>  use strict;<BR>  use SVG::Parser;<BR><BR>  die &quot;Usage: $0 &lt;file&gt;\n&quot; unless @ARGV;<BR><BR>  my $xml;<BR>  {<BR>      local $/=undef;<BR>      $xml=&lt;&gt;;<BR>  }<BR><BR>  my $parser=new <B>SVG::Parser</B>(-debug =&gt; 1);<BR>  my $svg=$parser-&gt;parse($xml);<BR>  print $svg-&gt;xmlify;<BR><BR>  and:<BR><BR>  #!/usr/bin/perl -w<BR>  use strict; <BR>  use <B>SVG::Parser</B> qw(SAX=XML::LibXML::Parser::SAX Expat SAX);<BR><BR>  die &quot;Usage: $0 &lt;file&gt;\n&quot; unless @ARGV;<BR>  my $svg=<B>SVG::Parser</B>-&gt;new()-&gt;parsefile($ARGV[0]);<BR>  print $svg-&gt;xmlify;<BR></pre></TD></TR></TABLE><A NAME="DESCRIPTION"></A><TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"><TR BGCOLOR="#ffae84"><TD><B>Description</B></TD><TD ALIGN="RIGHT"><A HREF="#TOP">top</A></TD></TR></TABLE><TABLE BORDER="0"><TR><TD COLSPAN="2"><pre><B>SVG::Parser</B> is an XML parser for SVG Documents. It takes XML as input and<BR>produces an SVG object as its output.<BR><BR><B>SVG::Parser</B> supports both XML::SAX and XML::Parser (Expat) parsers, with SAX<BR>preferred by default. Only one of these needs to be installed for SVG::Parser<BR>to function.<BR><BR>A list of preferred parsers may be specified in the import list - SVG::Parser<BR>will use the first parser that successfully loads. Some basic measures are taken<BR>to provide cross-compatability. Applications requiring more advanced parser<BR>features should use the relevant parser module directly; see<BR><a href="Parser/Expat.html" target="urlWin"><b>SVG::Parser::Expat</b></a> and <a href="Parser/SAX.html" target="urlWin"><b>SVG::Parser::SAX</b></a>.<BR></pre><pre><B>SVG::Parser</B> provides all methods supported by its parent parser class. In<BR>addition it provides the following:<BR><BR><BR><A NAME="_pod_* new([%attrs])">    * new([%attrs])</A><BR>    Create a new <B>SVG::Parser</B> object. Optional attributes may be passed as arguments;<BR>all attributes without a leading '-' prefix are passed to the parent<BR>constructor. For example:<BR><BR>       my $parser=new <B>SVG::Parser</B>(%parser_options);<BR><BR>    Note that parser options are dependant on which parser type is selected.<BR><BR>    Attributes with a leading '-' are processed by SVG::Parser. Currently the only <BR>recognised attribute is '-debug', which generates a simple but possibly useful<BR>debug trace of the parsing process to standard error. For example:<BR><BR>       my $parser=new <B>SVG::Parser</B>(-debug =&gt; 1);<BR><BR>    or:<BR><BR>       my $parser=<B>SVG::Parser</B>-&gt;new(-debug =&gt; 1);<BR><BR>    Attributes with a leading '--' are passed to the SVG constructor when creating<BR>the SVG object returned as the result of the parse:<BR><BR>       my $parser=new <B>SVG::Parser</B>(<BR>	-debug =&gt; 1,<BR>	--indent =&gt; &quot;\t&quot;,<BR>        --raiseerror =&gt; 1<BR>   );<BR><BR>    The leading '-' is stripped from attribute names passed this way, so this sets<BR>the '-indent' and '-raiseerror' attributes in the SVG module. See <a href="#_pod_SVG">SVG</a>     for a<BR>list of valid SVG options.<BR><BR><i>Note: technically the new() constructor is provided by either XML::SAX::Expat<BR>or SVG::Parser::SAX, not <B>SVG::Parser</B> itself. However, it operates identically<BR>in either case.</i>    <BR><BR><A NAME="_pod_* parse($xml)">    * parse($xml)</A><BR>    Parse an XML document and return an SVG object which may then be used to<BR>manipulate the SVG content before regenerating the output XML. For example:<BR><BR>        my $svg=$parser-&gt;parse($svgxml);<BR><BR>    Because the parse() method differs in use beteen XML::Parser and XML::SAX,<BR><B>SVG::Parser</B> provides its own parse() method. This calls the parent parser with<BR>the correct first argument when given either a filehandle or a string as input.<BR><BR>    Additional arguments are passed to the parent parser class, but since<BR>XML::Parser and XML::SAX parsers take options in different formats this is<BR>of limited use. <B>SVG::Parser</B> does not currently provide any translation of<BR>parser options.<BR><BR>    See <a href="Parser.html" target="urlWin"><b>XML::Parser</b></a>    , <a href="#_pod_XML::SAX">XML::SAX</a>    , and <a href="#_pod_XML::Parser::PerlSAX">XML::Parser::PerlSAX</a>     for other ways to<BR>parse input XML.<BR><BR><A NAME="_pod_* parse_file($filehandle|$filename)">    * parse_file($filehandle|$filename)</A><BR><A NAME="_pod_* parsefile($filehandle|$filename)">    * parsefile($filehandle|$filename)</A><BR>    Since the parse_file() method (XML::SAX) and parsefile() method (XML::Parser)<BR>differ in both name and usage, <B>SVG::Parser</B> provides its own version of both<BR>methods that determines whether the passed argument is a filehandle or<BR>a file name and directs the call to the appropriate parent parser method.<BR><BR>    Both methods will work equally well whichever parent parser class is in use:<BR><BR>        my $svg=$parser-&gt;parse_file($svgxml);<BR>    my $svg=$parser-&gt;parsefile($svgxml);<BR>    my $svg=$parser-&gt;parse_file(*SVGIN);<BR>    my $svg=$parser-&gt;parsefile(*SVGIN);<BR>    ...etc...<BR><BR>    These methods will also work when using SVG::Parser::Expat or SVG::Parser::SAX<BR>directly.<BR><BR><BR></pre><pre>None. However, a list of preferred parsers can be specified by passing the<BR>package name to <B>SVG::Parser</B> in the import list. This allows an SVG parser<BR>application to use the best parser available without knowing what XML parsers<BR>might be available on the target platform. SAX is generally preferred to Expat,<BR>but an Expat-based parser may be preferable to the slow Perl-based SAX<BR>parser XML::SAX::PurePerl. (See <a href="#_pod_XML::SAX::PurePerl">XML::SAX::PurePerl</a>.) <BR><BR>Each parser specification consists of one of the two supported SVG parsers,<BR>SVG::Parser::Expat or SVG::Parser::SAX, optionally followed by an '=' and an<BR>explicit parser package. For example:<BR><BR>    use <B>SVG::Parser</B> qw(SVG::Parser::SAX SVG::Parser::Expat);<BR><BR>Instead of specifying the full SVG parser name, 'Expat' and 'SAX' may be used as<BR>shorthand. For example:<BR><BR>    use <B>SVG::Parser</B> qw(SAX Expat);<BR><BR>Both the above examples produce the default behaviour. To prefer Expat over SAX<BR>use either of:<BR><BR>    use <B>SVG::Parser</B> qw(SVG::Parser::Expat SVG::Parser::SAX);<BR>    use <B>SVG::Parser</B> qw(Expat SAX);<BR><BR>To use Expat with an specific XML::Parser subclass:<BR><BR>    use <B>SVG::Parser</B> qw(SVG::Parser::Expat=My::XML::Parser::Subclass);<BR><BR>To use SAX with the XML::LibXML SAX parser:<BR><BR>    use <B>SVG::Parser</B> qw(SVG::Parser::SAX=XML::LibXML::SAX::Parser);<BR><BR>A number of specifications can be listed to have SVG::Parse try a number of<BR>possible parser alternatives in decreasing order of preference:<BR><BR>    use <B>SVG::Parser</B> qw(<BR>        SAX=My::SAXParser<BR>        Expat=My::Best::ExpatParser<BR>        SAX=XML::LibXML::SAX::Parser<BR>        Expat=My::Other::ExpatParser<BR>        Expat<BR>        SAX<BR>    )<BR><BR>This also works from the command line. For example:<BR><BR>    perl -MSVG::Parser=SAX mysvgapp.pl<BR>    perl -MSVG::Parser=Expat,SAX mysvgapp.pl<BR>    perl -MSVG::Parser=SAX=XML::LibXML::SAX::Parser,Expat mysvgapp.pl<BR><BR>To pass additional items in the import list to the parent Expat or SAX parser<BR>class, use additional '=' separators in the parser specification. In the case<BR>of XML::SAX a minimum version number may be required this way:<BR><BR>    # require version 1.40+ of the LibXML SAX parser, otherwise use Perl<BR>    use <B>SVG::Parser</B> qw(<BR>        SAX=XML::LibXML::SAX::Parser=1.40<BR>        SAX=XML::SAX::PurePerl<BR>    );<BR><BR>Similarly, from the command line:<BR><BR>    perl -MSVG::Parser=SAX=XML::LibXML::SAX::Parser=1.40,SAX=XML::SAX::PurePerl mysvgapp.pl<BR></pre><pre>See svgparse, svgparse2, and svgparse3 in the examples directory of the<BR>distribution, plus svgexpatparse and svgsaxparser for examples of using<BR>the SVG::Parser::Expat and SVG::Parser::SAX modules directly.<BR></pre></TD></TR></TABLE><A NAME="Methods"></A><TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"><TR BGCOLOR="#ffae84"><TD><B>Methods</B></TD><TD ALIGN="RIGHT"><A HREF="#TOP">top</A></TD></TR></TABLE><TABLE BORDER="1" CELLSPACING="5"><TR><TD><B>import</B></TD><TD><FONT COLOR="RED"><B>No description</B></FONT></TD><TD><A HREF="#CODE1">Code</A></TD></TR><TR><TD><B>parse</B></TD><TD><FONT COLOR="RED"><B>No description</B></FONT></TD><TD><A HREF="#CODE2">Code</A></TD></TR></TABLE><A NAME="MethDesc"></A><HR><H2>Methods description</H2><A NAME="MethCode"></A><HR><H2>Methods code</H2><TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"><TR BGCOLOR="#dcab68"><TD WIDTH="200"><A NAME="CODE1"></A><B>import</B></TD><TD>description</TD><TD WIDTH="30"><A HREF="#TOP">top</A></TD><TD WIDTH="30">prev</TD><TD WIDTH="30"><A HREF="#CODE2">next</A></TD></TR></TABLE><font color="#0000ff"><b>sub</b></font> <font color="#ff0000"><b>import</b></font> {<pre>    <font color="#0000ff"><b>my</b></font> <font color="#1f32ff">$package</font>=<font color="#4169e1"><b>shift</b></font>;    <font color="#0000ff"><b>my</b></font> <font color="#1f32ff">@importlist</font>;    <font color="#1f32ff">@ISA</font>=<font color="#1f32ff">@_</font> <font color="#0000ff"><b>if</b></font> <font color="#1f32ff">@_</font>;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -