xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefán Freyr Stefánsson <stef...@althingi.is>
Subject Re: Problems managing application-dependent attributes
Date Wed, 06 Aug 2003 14:59:30 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Try using a seperate namespace for your additional elements.

Here's an example of a document that works for me:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" 
xmlns:xlink="http://www.w3.org/1999/xlink" 
xmlns:embla="http://www.althingi.is/2003/embla" version="1" x="0" y="0" 
viewBox="0 0 2300 700">

   <defs>
      <g id="chair" style="stroke:#000000;stroke-width:1.0;">
         <rect
           width="400"
           height="400"
           rx="50"
           ry="50"
           x="0"
           y="0"
           id="seat"/>
      </g>
   </defs>

   <use xlink:href="#chair" x="50" y="50" embla:chair-id="1"/>
   <use xlink:href="#chair" x="500" y="100" embla:chair-id="2"/>
   <use xlink:href="#chair" x="950" y="150" embla:chair-id="3"/>
   <use xlink:href="#chair" x="1400" y="200" embla:chair-id="4"/>
   <use xlink:href="#chair" x="1850" y="250" embla:chair-id="5"/>
</svg>

Notice the embla:chair-id attributes in the <use> tag.  I'm not sure how you 
do that with the elements themselves, probably something like: 
<embla:my-tag>...</embla:my-tag>.

I did have a problem when I did this first since I didn't "define" the 
namespace "embla" at the beginning of the document.  So keep that in mind if 
you run into problems that you must define the namespace you're using using 
the xmlns thing at the top.

Kind regards, Stefan.

On Wednesday 06 August 2003 14:52, Marcelo Gilman wrote:
> Hi all,
> I am new using Batik so may be the my problem has a trivial solution, sorry
> if it is the case.  I need to insert some application-dependent attributes
> as for example:
>
> <svg>
>     <rect x="10" y="20" width="100" height="50"/>
>         <myProps>
>              <a>147</a>
>         </myProps>
>     </rect>
> </svg>
>
> In order to insert the new properties I simply do the following:
>
> SVGElement rectangle = (SVGElement) doc.createElementNS(svgNS, "rect");
> rectangle.setAttributeNS(null, "x", "10");
> rectangle.setAttributeNS(null, "y", "20");
> rectangle.setAttributeNS(null, "width", "100");
> rectangle.setAttributeNS(null, "height", "50");
> svgRoot.appendChild(rectangle);
> Element myProps = doc.createElement("myProps");
> myProps.setAttribute("a", "147");
> rectangle.appendChild(myProps);
>
> but I then have problems when trying to read it because I get the following
> exception:
>
> org.w3c.dom.DOMException: The current document is unable to create an
> element of the requested type (namespace: http://www.w3.org/2000/svg, name:
> myProps).
>
> I guess it is because I need to add the new definition to but it is not
> clear to me which is the proper way to do it using Batik.
>
> I would also need to listen for the svg-document reading process not at the
> begining,or the end as allows the SVGDocumentLoaderListener but for each
> read element.
>
> I would appreciate any help.
> Thanks a lot,
> Marcelo.
>
>
>
>
>
>
>
>
>
>
> ---------------------------------
> Internet GRATIS es Yahoo! Conexión.
> Usuario: yahoo; contraseña: yahoo
> Desde Buenos Aires: 4004-1010
> Más ciudades: clic aquí.

- -- 
Kind regards, Stefan

"XML is a giant step in no direction at all" (Erik Naggum)
"XML is a giant step in whichever direction you want it to be" (Andrew Hardie)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iQEVAwUBPzEX0r0ge6mq4AL2AQI7dAf/X4cdpeELOa9+R60bvel1gdpRvzH67EdK
Ni/mkn1SQymaAeHoHqmmeKhhd2md3QsB4Hzl/GOzZbMVOncYCFrzMi3L2OJ4ce68
3A6jz1NR/zAt5zLnB9jsJrFlTkbrLqoaJHpARa8TB6sxr5tl8WLrqdsGnVmdCidp
u/5nRS9LaqhyyibN7oGN5gdTyT7ZO3Jo+QjoGshsBZlotb5ZGJK4ZuIB2Q6e3HRt
wAJXfs4N3ezKSEHaqMacZsLy6WAyeqBgEZd9uQEbWGZpFb6KiphrSOE6SN0nG+VU
J1B1L7DrSQxf1NGFXuyh/bJjzjX1lwm40D5T/G/TxImkL3LO2SeCvw==
=57dq
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message