You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by prad <pr...@yahoo.co.in> on 2006/08/17 12:06:13 UTC

getting dom from svg file

Hi All,
Am finding difficult to get the dom for a svg file.    

Following sample code is workin fine for normal svg file
ie
 <svg>
.......
</svg>

    String parser = XMLResourceDescriptor.getXMLParserClassName();
    SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
    String uri = "somefile.svg";
    Document doc = f.createDocument(uri);

But If the svg file contains other tags like
<svg>
    <segments>
   </segments>
........
</svg>
am gettin error........any help please reply soon

Thanks & regards
prad
-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a5848619
Sent from the Batik - Users forum at Nabble.com.


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


Get bounding box from Text element

Posted by Dylan Browne <db...@mango-solutions.com>.
Hi all,

I'm having a problem getting the bounding box of a Text element. I have
trawled the archives, and from what I could see, I couldn't see anything
wrong with my code. I've included this below. When I run this I get the
following output.

The label is not null
The x is 100
The y is 100
The bounding box is null

As always, thanks in advance for any help here,

Dylan

--------------------------------------------

        labelText = (SVGOMTextElement)doc.getElementById("errorMessage");
        if(labelText == null){
            System.out.println("The label is null");
            return null;            
        }else{
            System.out.println("The label is not null");
            System.out.println("The x is " + labelText.getAttribute("x"));
            System.out.println("The y is " + labelText.getAttribute("y"));
        }
        SVGRect rect = labelText.getBBox();
        if(rect == null){
            System.out.println("The bounding box is null");
            return null;
        }else{
            System.out.println("The bounding box is not null");
        }


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


Re: getting dom from svg file

Posted by prad <pr...@yahoo.co.in>.
Hi wade,
Now i have decided to parse svg file as simple xml dom and change the
namespace of few elements and then use this modified file to create
SVGDOM.......does it works....if yes how do i change or move elements to
different namespace...

regards
 prad


G. Wade Johnson wrote:
> 
> On Thu, 17 Aug 2006 23:15:56 -0700 (PDT)
> prad <pr...@yahoo.co.in> wrote:
> 
>> 
>> Hi Thomas,
>> Thanks for the suggestion,but am not supposed to change svg file or
>> change
>> namespace
>> wat i have to do is to handle such elements by ignoring them
> 
> Well, if the elements are not SVG, then it is not SVG. If it is not SVG,
> you
> can't really expect Batik to handle it.
> 
> I'm not trying to be nasty, but this question comes up regularly. This is
> a
> basic XML issue. If you have elements that are not part of the definition
> of
> SVG, your file is not valid (by the definition of valid in the XML spec).
> 
> Namespaces are a well-defined mechanism for delaying with elements that
> are
> not part of application.
> 
> If you can't change the input, maybe you can run a post-processing pass
> with
> XSLT to convert the non-SVG elements to a different namespace before
> passing
> it to Batik.
> 
> G. Wade
> -- 
> Those who live by the sword get shot by those who don't.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a5920622
Sent from the Batik - Users forum at Nabble.com.


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


Re: getting dom from svg file

Posted by "G. Wade Johnson" <gw...@anomaly.org>.
On Thu, 17 Aug 2006 23:15:56 -0700 (PDT)
prad <pr...@yahoo.co.in> wrote:

> 
> Hi Thomas,
> Thanks for the suggestion,but am not supposed to change svg file or change
> namespace
> wat i have to do is to handle such elements by ignoring them

Well, if the elements are not SVG, then it is not SVG. If it is not SVG, you
can't really expect Batik to handle it.

I'm not trying to be nasty, but this question comes up regularly. This is a
basic XML issue. If you have elements that are not part of the definition of
SVG, your file is not valid (by the definition of valid in the XML spec).

Namespaces are a well-defined mechanism for delaying with elements that are
not part of application.

If you can't change the input, maybe you can run a post-processing pass with
XSLT to convert the non-SVG elements to a different namespace before passing
it to Batik.

G. Wade
-- 
Those who live by the sword get shot by those who don't.

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


Re: getting dom from svg file

Posted by "G. Wade Johnson" <gw...@anomaly.org>.
On Fri, 25 Aug 2006 06:58:49 -0400
thomas.deweese@kodak.com wrote:

> Hi Prad,
> 
> prad <pr...@yahoo.co.in> wrote on 08/24/2006 03:18:52 AM:
> 
> > Thank U very much....every thing is workin fine...But for few files 
> after
> > serializing if i try to create svgdom using SAXSVGDocumentFactory's
> > createSVGDoucment() method it giving some 
> java.io.UTFDataFomatException...
> 
>    I don't have a clue what would be causing this.  Does anyone
> else have any ideas.

My guess is that the file is not actually UTF8. Probably contains an invalid
character. Possibly one of the high-bit non-standard windows characters or
something.

> 
> > The exception was ...
> > java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
> >         at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown 
> Source)
> 
>     I have to wonder a little at this exception because AFAIK
> there is no invalid byte 1 of a 1-byte UTF-8 sequence 
> (a 1 byte UTF-8 sequence is any byte with the high bit clear,
> but in this case all of 0x00-0x7F I thought were valid).

If I remember correctly, most of the bytes between 0x00 and 0x1f are not valid
in XML (except cr, lf, and tab, of course).

Possibly a formfeed? I can see that accidentally ending up in a "text" file
and making the XML parser unhappy.

> 
> >         at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
> >         at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
> >         at org.apache.xerces.impl.XMLEntityScanner.skipChar(Unknown 
> Source)
> 
>     I wonder a little that this happend in xerces while loading
> an entity.  I wonder if it's a bug... You might try updating the
> Xerces you are using....

G. Wade

-- 
I've been living on the edge too long, where the winds of limbo roar.
                      -- "Veteran of Psychic Wars", Blue Oyster Cult

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


Re: getting dom from svg file

Posted by prad <pr...@yahoo.co.in>.
Hi Thomas,

Now my job is to split or divide a big svg document to many piece of svg
files....ie suppose i have a Sample.svg....this should be divided into
Sample1.svg,Sample2.svg............and more. Is it possible to do like this 

Thanks & Regards
Prad

thomas.deweese wrote:
> 
> Hi Prad,
> 
> prad <pr...@yahoo.co.in> wrote on 08/30/2006 05:57:05 AM:
> 
>> I just checked the difference between the original file and the file 
> after
>> serializing...In second file one character is not getting written.(§ 
> ..this
>> charaters is written as § without first character)...
> 
>     Sounds like a problem in the serializer.  You might try using 
> batik.dom.util.DOMUtilities.writeDocument.
> 
>> Any way I have another question ....
>> I have a use elements inside <g> element...
>> 
>>         <use x="269.707136" xlink:href="#Global_1146" y="1426.839960"/>
> 
>> I cannot get the attribute xlink:href.....If i check weather the 
> attribute
>> exists using element.getAttribute("xlink:href") its returning 
> false....But
>> if i use the below code
> 
>    This is the 'href' attribute in the 'xlink' namespace so you need to 
> use
> the getAttributeNS version:
> 
>  
> element.getAttributeNS(org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI,
>                                      "xlink:href");
> 
>> NamedNodeMap nnm = child.getAttributes(); 
>> for(int k=0;k<nnm.getLength();k++)
>> {
>>    System.out.println("attributes are " + nnm.item(k).getNodeName());    
>  
>> }
>> 
>> It displays
>> 
>> attributes are x
>> attributes are y
>> attributes are xmlns:xlink
>> attributes are xlink:href
>> attributes are xlink:type
>> attributes are xlink:actuate
>> attributes are xlink:show
>> 
>> Any idea
>> 
>> Thanks & Regards
>> Prad
>> 
>> thomas.deweese wrote:
>> > 
>> > Hi Prad,
>> > 
>> > prad <pr...@yahoo.co.in> wrote on 08/24/2006 03:18:52 AM:
>> > 
>> >> Thank U very much....every thing is workin fine...But for few files 
>> > after
>> >> serializing if i try to create svgdom using SAXSVGDocumentFactory's
>> >> createSVGDoucment() method it giving some 
>> > java.io.UTFDataFomatException...
>> > 
>> >    I don't have a clue what would be causing this.  Does anyone
>> > else have any ideas.
>> > 
>> >> The exception was ...
>> >> java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 
> sequence.
>> >>         at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown 
>> > Source)
>> > 
>> >     I have to wonder a little at this exception because AFAIK
>> > there is no invalid byte 1 of a 1-byte UTF-8 sequence 
>> > (a 1 byte UTF-8 sequence is any byte with the high bit clear,
>> > but in this case all of 0x00-0x7F I thought were valid).
>> > 
>> >>         at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
>> >>         at org.apache.xerces.impl.XMLEntityScanner.load(Unknown 
> Source)
>> >>         at org.apache.xerces.impl.XMLEntityScanner.skipChar(Unknown 
>> > Source)
>> > 
>> >     I wonder a little that this happend in xerces while loading
>> > an entity.  I wonder if it's a bug... You might try updating the
>> > Xerces you are using....
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail: 
> batik-users-help@xmlgraphics.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context: 
> http://www.nabble.com/getting-dom-from-svg-file-
>> tf2120596.html#a6055774
>> Sent from the Batik - Users forum at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a6132437
Sent from the Batik - Users forum at Nabble.com.


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


Re: getting dom from svg file

Posted by prad <pr...@yahoo.co.in>.
Hi Thomas,

I have a sensitive bounding box of svg document (-1044.5	-1370.5	    3220.0 
2176.0)....From this rectangle i need to take out one rectangle with the
specified x,y,width and height ...say(-1044.5	-1370.5	  600	600) and write
it to a file.Is it possible and how can i achieve it.

Thanks and regards
Prad

thomas.deweese wrote:
> 
> Hi Prad,
> 
>     The error means what it says, it wants an ' java.io.Writer'
> in the TranscoderOutput, not a simple IO stream.
> If you don't care much about the encoding you can use
> the OutputStreamWriter to wrap your output stream.
> 
> prad <pr...@yahoo.co.in> wrote on 09/28/2006 07:43:23 AM:
> 
>> But its giving following exception....Am i goin in a wrong way..Plz help 
> me
>> out
>> 
>> Exception :Exception in thread "main" java.lang.Error: Writer expected
>>    at 
> org.apache.batik.transcoder.svg2svg.SVGTranscoder.transcode(Unknown
>> Source)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a6614849
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: getting dom from svg file

Posted by prad <pr...@yahoo.co.in>.
Hi Thomas,

I have a sensitive bounding box of svg document (-1044.5 ,	-1370.5 ,	   
3220.0 , 	2176.0)....From this rectangle i need to take out one rectangle
with the specified x,y,width and height ...say(-1044.5	-1370.5	  600	600)
and write it to a file.Is it possible and how can i achieve it.

Thanks and regards
Prad

thomas.deweese wrote:
> 
> Hi Prad,
> 
>     The error means what it says, it wants an ' java.io.Writer'
> in the TranscoderOutput, not a simple IO stream.
> If you don't care much about the encoding you can use
> the OutputStreamWriter to wrap your output stream.
> 
> prad <pr...@yahoo.co.in> wrote on 09/28/2006 07:43:23 AM:
> 
>> But its giving following exception....Am i goin in a wrong way..Plz help 
> me
>> out
>> 
>> Exception :Exception in thread "main" java.lang.Error: Writer expected
>>    at 
> org.apache.batik.transcoder.svg2svg.SVGTranscoder.transcode(Unknown
>> Source)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a6614849
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: getting dom from svg file

Posted by th...@kodak.com.
Hi Prad,

    The error means what it says, it wants an ' java.io.Writer'
in the TranscoderOutput, not a simple IO stream.
If you don't care much about the encoding you can use
the OutputStreamWriter to wrap your output stream.

prad <pr...@yahoo.co.in> wrote on 09/28/2006 07:43:23 AM:

> But its giving following exception....Am i goin in a wrong way..Plz help 
me
> out
> 
> Exception :Exception in thread "main" java.lang.Error: Writer expected
>    at 
org.apache.batik.transcoder.svg2svg.SVGTranscoder.transcode(Unknown
> Source)


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


Re: getting dom from svg file

Posted by prad <pr...@yahoo.co.in>.
Hi Thomas,
Can i Write svgdom to a file using 
org.apache.batik.transcoder.svg2svg.SVGTranscoder;

I tried it but its giving error

       SVGTranscoder t = new SVGTranscoder();
      // t.addTranscodingHint(SVGTranscoder.KEY_DOCUMENT_WIDTH, new
Integer(1));
       TranscoderInput input = new TranscoderInput(doc);
       OutputStream ostream = new FileOutputStream(" uri");
       //OutputManager output = new OutputManager(printer,writer);
        TranscoderOutput output = new TranscoderOutput(ostream);
        t.transcode(input,output);
        ostream.flush();
        ostream.close();
But its giving following exception....Am i goin in a wrong way..Plz help me
out

Exception :Exception in thread "main" java.lang.Error: Writer expected
	at org.apache.batik.transcoder.svg2svg.SVGTranscoder.transcode(Unknown
Source)
	at com.pradeep.split.SaveAsJpegTiles.main(SaveAsSVG.java:71)

Thanks & Regards
Prad





thomas.deweese wrote:
> 
> Hi Prad,
> 
> prad <pr...@yahoo.co.in> wrote on 08/30/2006 05:57:05 AM:
> 
>> I just checked the difference between the original file and the file 
> after
>> serializing...In second file one character is not getting written.(?? 
> ..this
>> charaters is written as ? without first character)...
> 
>     Sounds like a problem in the serializer.  You might try using 
> batik.dom.util.DOMUtilities.writeDocument.
> 
>> Any way I have another question ....
>> I have a use elements inside <g> element...
>> 
>>         <use x="269.707136" xlink:href="#Global_1146" y="1426.839960"/>
> 
>> I cannot get the attribute xlink:href.....If i check weather the 
> attribute
>> exists using element.getAttribute("xlink:href") its returning 
> false....But
>> if i use the below code
> 
>    This is the 'href' attribute in the 'xlink' namespace so you need to 
> use
> the getAttributeNS version:
> 
>  
> element.getAttributeNS(org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI,
>                                      "xlink:href");
> 
>> NamedNodeMap nnm = child.getAttributes(); 
>> for(int k=0;k<nnm.getLength();k++)
>> {
>>    System.out.println("attributes are " + nnm.item(k).getNodeName());    
>  
>> }
>> 
>> It displays
>> 
>> attributes are x
>> attributes are y
>> attributes are xmlns:xlink
>> attributes are xlink:href
>> attributes are xlink:type
>> attributes are xlink:actuate
>> attributes are xlink:show
>> 
>> Any idea
>> 
>> Thanks & Regards
>> Prad
>> 
>> thomas.deweese wrote:
>> > 
>> > Hi Prad,
>> > 
>> > prad <pr...@yahoo.co.in> wrote on 08/24/2006 03:18:52 AM:
>> > 
>> >> Thank U very much....every thing is workin fine...But for few files 
>> > after
>> >> serializing if i try to create svgdom using SAXSVGDocumentFactory's
>> >> createSVGDoucment() method it giving some 
>> > java.io.UTFDataFomatException...
>> > 
>> >    I don't have a clue what would be causing this.  Does anyone
>> > else have any ideas.
>> > 
>> >> The exception was ...
>> >> java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 
> sequence.
>> >>         at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown 
>> > Source)
>> > 
>> >     I have to wonder a little at this exception because AFAIK
>> > there is no invalid byte 1 of a 1-byte UTF-8 sequence 
>> > (a 1 byte UTF-8 sequence is any byte with the high bit clear,
>> > but in this case all of 0x00-0x7F I thought were valid).
>> > 
>> >>         at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
>> >>         at org.apache.xerces.impl.XMLEntityScanner.load(Unknown 
> Source)
>> >>         at org.apache.xerces.impl.XMLEntityScanner.skipChar(Unknown 
>> > Source)
>> > 
>> >     I wonder a little that this happend in xerces while loading
>> > an entity.  I wonder if it's a bug... You might try updating the
>> > Xerces you are using....
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail: 
> batik-users-help@xmlgraphics.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context: 
> http://www.nabble.com/getting-dom-from-svg-file-
>> tf2120596.html#a6055774
>> Sent from the Batik - Users forum at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a6544801
Sent from the Batik - Users mailing list archive at Nabble.com.


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


Re: getting dom from svg file

Posted by th...@kodak.com.
Hi Prad,

prad <pr...@yahoo.co.in> wrote on 08/30/2006 05:57:05 AM:

> I just checked the difference between the original file and the file 
after
> serializing...In second file one character is not getting written.(§ 
..this
> charaters is written as § without first character)...

    Sounds like a problem in the serializer.  You might try using 
batik.dom.util.DOMUtilities.writeDocument.

> Any way I have another question ....
> I have a use elements inside <g> element...
> 
>         <use x="269.707136" xlink:href="#Global_1146" y="1426.839960"/>

> I cannot get the attribute xlink:href.....If i check weather the 
attribute
> exists using element.getAttribute("xlink:href") its returning 
false....But
> if i use the below code

   This is the 'href' attribute in the 'xlink' namespace so you need to 
use
the getAttributeNS version:

 
element.getAttributeNS(org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI,
                                     "xlink:href");

> NamedNodeMap nnm = child.getAttributes(); 
> for(int k=0;k<nnm.getLength();k++)
> {
>    System.out.println("attributes are " + nnm.item(k).getNodeName());    
 
> }
> 
> It displays
> 
> attributes are x
> attributes are y
> attributes are xmlns:xlink
> attributes are xlink:href
> attributes are xlink:type
> attributes are xlink:actuate
> attributes are xlink:show
> 
> Any idea
> 
> Thanks & Regards
> Prad
> 
> thomas.deweese wrote:
> > 
> > Hi Prad,
> > 
> > prad <pr...@yahoo.co.in> wrote on 08/24/2006 03:18:52 AM:
> > 
> >> Thank U very much....every thing is workin fine...But for few files 
> > after
> >> serializing if i try to create svgdom using SAXSVGDocumentFactory's
> >> createSVGDoucment() method it giving some 
> > java.io.UTFDataFomatException...
> > 
> >    I don't have a clue what would be causing this.  Does anyone
> > else have any ideas.
> > 
> >> The exception was ...
> >> java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 
sequence.
> >>         at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown 
> > Source)
> > 
> >     I have to wonder a little at this exception because AFAIK
> > there is no invalid byte 1 of a 1-byte UTF-8 sequence 
> > (a 1 byte UTF-8 sequence is any byte with the high bit clear,
> > but in this case all of 0x00-0x7F I thought were valid).
> > 
> >>         at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
> >>         at org.apache.xerces.impl.XMLEntityScanner.load(Unknown 
Source)
> >>         at org.apache.xerces.impl.XMLEntityScanner.skipChar(Unknown 
> > Source)
> > 
> >     I wonder a little that this happend in xerces while loading
> > an entity.  I wonder if it's a bug... You might try updating the
> > Xerces you are using....
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: 
http://www.nabble.com/getting-dom-from-svg-file-
> tf2120596.html#a6055774
> Sent from the Batik - Users forum at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Re: getting dom from svg file

Posted by prad <pr...@yahoo.co.in>.
Hi Thomas,

I just checked the difference between the original file and the file after
serializing...In second file one character is not getting written.(§ ..this
charaters is written as § without first character)...Any way I have another
question ....
I have a use elements inside <g> element...

<g id="4598#400" style="stroke:rgb(255,190,201);fill:rgb(255,190,201)"
varType="meVar">
        <use x="269.707136" xlink:href="#Global_1146" y="1426.839960"/>
      </g>

I cannot get the attribute xlink:href.....If i check wether the attribute
exists using element.getAttribute("xlink:href") its returning false....But
if i use the below code

NamedNodeMap nnm = child.getAttributes();									
for(int k=0;k<nnm.getLength();k++)
{
	System.out.println("attributes are " + nnm.item(k).getNodeName());										
}

It displays

attributes are x
attributes are y
attributes are xmlns:xlink
attributes are xlink:href
attributes are xlink:type
attributes are xlink:actuate
attributes are xlink:show

Any idea

Thanks & Regards
Prad

thomas.deweese wrote:
> 
> Hi Prad,
> 
> prad <pr...@yahoo.co.in> wrote on 08/24/2006 03:18:52 AM:
> 
>> Thank U very much....every thing is workin fine...But for few files 
> after
>> serializing if i try to create svgdom using SAXSVGDocumentFactory's
>> createSVGDoucment() method it giving some 
> java.io.UTFDataFomatException...
> 
>    I don't have a clue what would be causing this.  Does anyone
> else have any ideas.
> 
>> The exception was ...
>> java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
>>         at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown 
> Source)
> 
>     I have to wonder a little at this exception because AFAIK
> there is no invalid byte 1 of a 1-byte UTF-8 sequence 
> (a 1 byte UTF-8 sequence is any byte with the high bit clear,
> but in this case all of 0x00-0x7F I thought were valid).
> 
>>         at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
>>         at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
>>         at org.apache.xerces.impl.XMLEntityScanner.skipChar(Unknown 
> Source)
> 
>     I wonder a little that this happend in xerces while loading
> an entity.  I wonder if it's a bug... You might try updating the
> Xerces you are using....
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a6055774
Sent from the Batik - Users forum at Nabble.com.


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


Re: getting dom from svg file

Posted by th...@kodak.com.
Hi Prad,

prad <pr...@yahoo.co.in> wrote on 08/24/2006 03:18:52 AM:

> Thank U very much....every thing is workin fine...But for few files 
after
> serializing if i try to create svgdom using SAXSVGDocumentFactory's
> createSVGDoucment() method it giving some 
java.io.UTFDataFomatException...

   I don't have a clue what would be causing this.  Does anyone
else have any ideas.

> The exception was ...
> java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
>         at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown 
Source)

    I have to wonder a little at this exception because AFAIK
there is no invalid byte 1 of a 1-byte UTF-8 sequence 
(a 1 byte UTF-8 sequence is any byte with the high bit clear,
but in this case all of 0x00-0x7F I thought were valid).

>         at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
>         at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
>         at org.apache.xerces.impl.XMLEntityScanner.skipChar(Unknown 
Source)

    I wonder a little that this happend in xerces while loading
an entity.  I wonder if it's a bug... You might try updating the
Xerces you are using....


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


Re: getting dom from svg file

Posted by prad <pr...@yahoo.co.in>.
Hi Thomas,

Thank U very much....every thing is workin fine...But for few files after
serializing if i try to create svgdom using SAXSVGDocumentFactory's
createSVGDoucment() method it giving some java.io.UTFDataFomatException...

For serializing i used the below code


	   		OutputFormat format = new OutputFormat(document,"UTF-8",false);
	   		
	   		String encoding = format.getEncoding();
	   		
	   		System.out.println("Encoding is : " + encoding);
			format.setLineSeparator(LineSeparator.Windows);
			format.setIndenting(true);
			format.setLineWidth(0);             
			format.setPreserveSpace(true);
			XMLSerializer serializer = new XMLSerializer (
			    new FileWriter("C:/Documents and
Settings/ic00t115/Desktop/Generated/Testing.svg"), format);
			serializer.asDOMSerializer();
			serializer.serialize(document);

The exception was ...
java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
        at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source)
        at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
        at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
        at org.apache.xerces.impl.XMLEntityScanner.skipChar(Unknown Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at
org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)
        at
org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)
        at
org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown
Source)
        at
org.apache.batik.dom.svg.SAXSVGDocumentFactory.createSVGDocument(Unknown
Source)
This is not happening for all the files but for some large files....

Thanks for ur great support

Regard 
Prad

thomas.deweese wrote:
> 
> Hi Prad,
> 
> prad <pr...@yahoo.co.in> wrote on 08/23/2006 01:47:47 AM:
> 
>> Idea is good..I tried it out.Am getting one problem ie after replacing 
> new
>> element with different namespace and serialize the dom to xml....new xml
>> file is taking the  global namespace ie"http://www.w3.org/2000/svg" 
> instead
>> of "http://myNameSpace.org"......Any idea about where i might be wrong
> 
>    You need to declare and use a new namespace prefix for the element.
> 
>          String XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";
> 
>            // Declare the new namespace prefix (for serialization)
>            Element root    = doc.getRootElement();
>            root.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:myNS", 
> newNamespace);
> 
>            // Use the new namespace prefix in the document.
>          Element newElem = doc.createElementNS(newNamespace, 
>  "myNS:"+problem.getLocalName());
> 
>> thomas.deweese wrote:
>> > 
>> > Hi Prad,
>> > 
>> >      Do not send the same message multiple times to the list.
>> > 
>> > prad <pr...@yahoo.co.in> wrote on 08/22/2006 03:20:03 AM:
>> > 
>> >> Now i have decided to parse svg file as simple xml dom and change the
>> >> namespace of few elements and then use this modified file to create
>> >> SVGDOM.......does it works....if yes,
>> > 
>> >    Yes, this will work.  Since you are supposed to ignore the 
>> > elements you could also remove them (this is simpler).
>> > 
>> >> how do i change or move elements to different namespace...
>> > 
>> >    I would suggest using the following to locate the problem elements: 
> 
>> >         Element.getElementsByTagNameNS(String namespace, String 
> tagName)
>> > 
>> >    Then the simplest thing to do is remove them from the DOM:
>> > 
>> >         Element problem = nodeList.get(i);
>> >         problem.getParentNode().removeChild(problem);
>> > 
>> >    Moving them to another namespace is a little tricker.  First
>> > you need to create a new element in the new namespace:
>> > 
>> >         Element newElem = doc.createElementNS(newNamespace, 
>> > problem.getTagName());
>> >         // Then copy the attributes from the problem node to the new 
> node.
>> >         NamedNodeMap nnm = problem.getAttributes();
>> >         int len = nnm.getLength();
>> >         for (int i=0; i<len; i++) {
>> >                 Attr a = (Attr)nnm.get(i);
>> >                 Attr newAttr = (Attr)doc.importNode(a, true);
>> >                 newElem.setAttributeNode(newAttr);
>> >         }
>> > 
>> >         Then you need to replace the problem element with the
>> > new Element:
>> > 
>> >         problem.getParentNode().replaceChild(newElem, problem);
>> > 
>> >         This get's a bit more complex if the elements that need to
>> > be moved may have children that also need to be moved... You basically
>> > need to walk the problem element's children running the above code
>> > on each of them an appending them to 'newElem'.
>> > 
>> >    (The above is untested 'psuedo code')
>> >    Good luck!
>> > 
>> >> thomas.deweese wrote:
>> >> > 
>> >> > Hi Prad,
>> >> > 
>> >> > prad <pr...@yahoo.co.in> wrote on 08/18/2006 02:15:56 AM:
>> >> > 
>> >> >> Thanks for the suggestion,but am not supposed to change svg file 
> or 
>> >> > change
>> >> >> namespace wat i have to do is to handle such elements by ignoring 
>> > them
>> >> > 
>> >> >     I will _very_ strong recommend that you fix the files.
>> >> > Changing tools to work around broken files is 100% always the
>> >> > wrong answer to the problem.
>> >> > 
>> >> >     That said you can try creating a subclass of 
>> >> > batik.dom.svg.SVGDOMImplementation that replaces the 
>> >> > createElement & createElementNS methods. 
>> >> > 
>> >> >     This is about all the help I'll give on this topic
>> >> > as I consider this the totally wrong way to approach 
>> >> > the problem.
>> >> > 
>> >> >     Good luck!
>> >> > 
>> >> >> thomas.deweese wrote:
>> >> >> > 
>> >> >> > Hi Prad,
>> >> >> > 
>> >> >> > prad <pr...@yahoo.co.in> wrote on 08/17/2006 06:06:13 AM:
>> >> >> > 
>> >> >> >> Am finding difficult to get the dom for a svg file. 
>> >> >> > 
>> >> >> >    Actually it looks like you are getting DOM fine for
>> >> >> > SVG files.  It is files that look a little like an
>> >> >> > SVG file but aren't that causing you problems (as they should).
>> >> >> > 
>> >> >> >> But If the svg file contains other tags like
>> >> >> > 
>> >> >> >    This is not a valid SVG file:
>> >> >> >> <svg>
>> >> >> >>     <segments>
>> >> >> >>    </segments>
>> >> >> > 
>> >> >> >    I suggest you fix it by moving the non-SVG elements 
>> >> >> > out of the SVG namespace:
>> >> >> >    <svg xmlns:prad="http://prad.org/">
>> >> >> >         <prad:segments>
>> >> >> >         </prad:segments>
>> >> >> >    </svg>
>> >> >> > 
>> >> >> > 
>> >> >> > 
>> > ---------------------------------------------------------------------
>> >> >> > To unsubscribe, e-mail: 
>> > batik-users-unsubscribe@xmlgraphics.apache.org
>> >> >> > For additional commands, e-mail: 
>> >> > batik-users-help@xmlgraphics.apache.org
>> >> >> > 
>> >> >> > 
>> >> >> > 
>> >> >> 
>> >> >> -- 
>> >> >> View this message in context: 
>> >> > http://www.nabble.com/getting-dom-from-svg-file-
>> >> >> tf2120596.html#a5860806
>> >> >> Sent from the Batik - Users forum at Nabble.com.
>> >> >> 
>> >> >> 
>> >> >> 
> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: 
>> > batik-users-unsubscribe@xmlgraphics.apache.org
>> >> >> For additional commands, e-mail: 
>> > batik-users-help@xmlgraphics.apache.org
>> >> >> 
>> >> > 
>> >> > 
>> >> > 
> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: 
> batik-users-unsubscribe@xmlgraphics.apache.org
>> >> > For additional commands, e-mail: 
>> > batik-users-help@xmlgraphics.apache.org
>> >> > 
>> >> > 
>> >> > 
>> >> 
>> >> -- 
>> >> View this message in context: 
>> > http://www.nabble.com/getting-dom-from-svg-file-
>> >> tf2120596.html#a5920621
>> >> Sent from the Batik - Users forum at Nabble.com.
>> >> 
>> >> 
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: 
> batik-users-unsubscribe@xmlgraphics.apache.org
>> >> For additional commands, e-mail: 
> batik-users-help@xmlgraphics.apache.org
>> >> 
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail: 
> batik-users-help@xmlgraphics.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context: 
> http://www.nabble.com/getting-dom-from-svg-file-
>> tf2120596.html#a5938589
>> Sent from the Batik - Users forum at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a5959014
Sent from the Batik - Users forum at Nabble.com.


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


Re: getting dom from svg file

Posted by th...@kodak.com.
Hi Prad,

prad <pr...@yahoo.co.in> wrote on 08/23/2006 01:47:47 AM:

> Idea is good..I tried it out.Am getting one problem ie after replacing 
new
> element with different namespace and serialize the dom to xml....new xml
> file is taking the  global namespace ie"http://www.w3.org/2000/svg" 
instead
> of "http://myNameSpace.org"......Any idea about where i might be wrong

   You need to declare and use a new namespace prefix for the element.

         String XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";

           // Declare the new namespace prefix (for serialization)
           Element root    = doc.getRootElement();
           root.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:myNS", 
newNamespace);

           // Use the new namespace prefix in the document.
         Element newElem = doc.createElementNS(newNamespace, 
 "myNS:"+problem.getLocalName());

> thomas.deweese wrote:
> > 
> > Hi Prad,
> > 
> >      Do not send the same message multiple times to the list.
> > 
> > prad <pr...@yahoo.co.in> wrote on 08/22/2006 03:20:03 AM:
> > 
> >> Now i have decided to parse svg file as simple xml dom and change the
> >> namespace of few elements and then use this modified file to create
> >> SVGDOM.......does it works....if yes,
> > 
> >    Yes, this will work.  Since you are supposed to ignore the 
> > elements you could also remove them (this is simpler).
> > 
> >> how do i change or move elements to different namespace...
> > 
> >    I would suggest using the following to locate the problem elements: 

> >         Element.getElementsByTagNameNS(String namespace, String 
tagName)
> > 
> >    Then the simplest thing to do is remove them from the DOM:
> > 
> >         Element problem = nodeList.get(i);
> >         problem.getParentNode().removeChild(problem);
> > 
> >    Moving them to another namespace is a little tricker.  First
> > you need to create a new element in the new namespace:
> > 
> >         Element newElem = doc.createElementNS(newNamespace, 
> > problem.getTagName());
> >         // Then copy the attributes from the problem node to the new 
node.
> >         NamedNodeMap nnm = problem.getAttributes();
> >         int len = nnm.getLength();
> >         for (int i=0; i<len; i++) {
> >                 Attr a = (Attr)nnm.get(i);
> >                 Attr newAttr = (Attr)doc.importNode(a, true);
> >                 newElem.setAttributeNode(newAttr);
> >         }
> > 
> >         Then you need to replace the problem element with the
> > new Element:
> > 
> >         problem.getParentNode().replaceChild(newElem, problem);
> > 
> >         This get's a bit more complex if the elements that need to
> > be moved may have children that also need to be moved... You basically
> > need to walk the problem element's children running the above code
> > on each of them an appending them to 'newElem'.
> > 
> >    (The above is untested 'psuedo code')
> >    Good luck!
> > 
> >> thomas.deweese wrote:
> >> > 
> >> > Hi Prad,
> >> > 
> >> > prad <pr...@yahoo.co.in> wrote on 08/18/2006 02:15:56 AM:
> >> > 
> >> >> Thanks for the suggestion,but am not supposed to change svg file 
or 
> >> > change
> >> >> namespace wat i have to do is to handle such elements by ignoring 
> > them
> >> > 
> >> >     I will _very_ strong recommend that you fix the files.
> >> > Changing tools to work around broken files is 100% always the
> >> > wrong answer to the problem.
> >> > 
> >> >     That said you can try creating a subclass of 
> >> > batik.dom.svg.SVGDOMImplementation that replaces the 
> >> > createElement & createElementNS methods. 
> >> > 
> >> >     This is about all the help I'll give on this topic
> >> > as I consider this the totally wrong way to approach 
> >> > the problem.
> >> > 
> >> >     Good luck!
> >> > 
> >> >> thomas.deweese wrote:
> >> >> > 
> >> >> > Hi Prad,
> >> >> > 
> >> >> > prad <pr...@yahoo.co.in> wrote on 08/17/2006 06:06:13 AM:
> >> >> > 
> >> >> >> Am finding difficult to get the dom for a svg file. 
> >> >> > 
> >> >> >    Actually it looks like you are getting DOM fine for
> >> >> > SVG files.  It is files that look a little like an
> >> >> > SVG file but aren't that causing you problems (as they should).
> >> >> > 
> >> >> >> But If the svg file contains other tags like
> >> >> > 
> >> >> >    This is not a valid SVG file:
> >> >> >> <svg>
> >> >> >>     <segments>
> >> >> >>    </segments>
> >> >> > 
> >> >> >    I suggest you fix it by moving the non-SVG elements 
> >> >> > out of the SVG namespace:
> >> >> >    <svg xmlns:prad="http://prad.org/">
> >> >> >         <prad:segments>
> >> >> >         </prad:segments>
> >> >> >    </svg>
> >> >> > 
> >> >> > 
> >> >> > 
> > ---------------------------------------------------------------------
> >> >> > To unsubscribe, e-mail: 
> > batik-users-unsubscribe@xmlgraphics.apache.org
> >> >> > For additional commands, e-mail: 
> >> > batik-users-help@xmlgraphics.apache.org
> >> >> > 
> >> >> > 
> >> >> > 
> >> >> 
> >> >> -- 
> >> >> View this message in context: 
> >> > http://www.nabble.com/getting-dom-from-svg-file-
> >> >> tf2120596.html#a5860806
> >> >> Sent from the Batik - Users forum at Nabble.com.
> >> >> 
> >> >> 
> >> >> 
---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: 
> > batik-users-unsubscribe@xmlgraphics.apache.org
> >> >> For additional commands, e-mail: 
> > batik-users-help@xmlgraphics.apache.org
> >> >> 
> >> > 
> >> > 
> >> > 
---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: 
batik-users-unsubscribe@xmlgraphics.apache.org
> >> > For additional commands, e-mail: 
> > batik-users-help@xmlgraphics.apache.org
> >> > 
> >> > 
> >> > 
> >> 
> >> -- 
> >> View this message in context: 
> > http://www.nabble.com/getting-dom-from-svg-file-
> >> tf2120596.html#a5920621
> >> Sent from the Batik - Users forum at Nabble.com.
> >> 
> >> 
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: 
batik-users-unsubscribe@xmlgraphics.apache.org
> >> For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> >> 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: 
http://www.nabble.com/getting-dom-from-svg-file-
> tf2120596.html#a5938589
> Sent from the Batik - Users forum at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Re: getting dom from svg file

Posted by prad <pr...@yahoo.co.in>.
Hi Thomas,

Idea is good..I tried it out.Am getting one problem ie after replacing new
element with different namespace and serialize the dom to xml....new xml
file is taking the  global namespace ie"http://www.w3.org/2000/svg" instead
of "http://myNameSpace.org"......Any idea about where i might be wrong

Regards
Prad 

thomas.deweese wrote:
> 
> Hi Prad,
> 
>      Do not send the same message multiple times to the list.
> 
> prad <pr...@yahoo.co.in> wrote on 08/22/2006 03:20:03 AM:
> 
>> Now i have decided to parse svg file as simple xml dom and change the
>> namespace of few elements and then use this modified file to create
>> SVGDOM.......does it works....if yes,
> 
>    Yes, this will work.  Since you are supposed to ignore the 
> elements you could also remove them (this is simpler).
> 
>> how do i change or move elements to different namespace...
> 
>    I would suggest using the following to locate the problem elements: 
>         Element.getElementsByTagNameNS(String namespace, String tagName)
> 
>    Then the simplest thing to do is remove them from the DOM:
> 
>         Element problem = nodeList.get(i);
>         problem.getParentNode().removeChild(problem);
> 
>    Moving them to another namespace is a little tricker.  First
> you need to create a new element in the new namespace:
> 
>         Element newElem = doc.createElementNS(newNamespace, 
> problem.getTagName());
>         // Then copy the attributes from the problem node to the new node.
>         NamedNodeMap nnm = problem.getAttributes();
>         int len = nnm.getLength();
>         for (int i=0; i<len; i++) {
>                 Attr a = (Attr)nnm.get(i);
>                 Attr newAttr = (Attr)doc.importNode(a, true);
>                 newElem.setAttributeNode(newAttr);
>         }
> 
>         Then you need to replace the problem element with the
> new Element:
> 
>         problem.getParentNode().replaceChild(newElem, problem);
> 
>         This get's a bit more complex if the elements that need to
> be moved may have children that also need to be moved... You basically
> need to walk the problem element's children running the above code
> on each of them an appending them to 'newElem'.
> 
>    (The above is untested 'psuedo code')
>    Good luck!
> 
>> thomas.deweese wrote:
>> > 
>> > Hi Prad,
>> > 
>> > prad <pr...@yahoo.co.in> wrote on 08/18/2006 02:15:56 AM:
>> > 
>> >> Thanks for the suggestion,but am not supposed to change svg file or 
>> > change
>> >> namespace wat i have to do is to handle such elements by ignoring 
> them
>> > 
>> >     I will _very_ strong recommend that you fix the files.
>> > Changing tools to work around broken files is 100% always the
>> > wrong answer to the problem.
>> > 
>> >     That said you can try creating a subclass of 
>> > batik.dom.svg.SVGDOMImplementation that replaces the 
>> > createElement & createElementNS methods. 
>> > 
>> >     This is about all the help I'll give on this topic
>> > as I consider this the totally wrong way to approach 
>> > the problem.
>> > 
>> >     Good luck!
>> > 
>> >> thomas.deweese wrote:
>> >> > 
>> >> > Hi Prad,
>> >> > 
>> >> > prad <pr...@yahoo.co.in> wrote on 08/17/2006 06:06:13 AM:
>> >> > 
>> >> >> Am finding difficult to get the dom for a svg file. 
>> >> > 
>> >> >    Actually it looks like you are getting DOM fine for
>> >> > SVG files.  It is files that look a little like an
>> >> > SVG file but aren't that causing you problems (as they should).
>> >> > 
>> >> >> But If the svg file contains other tags like
>> >> > 
>> >> >    This is not a valid SVG file:
>> >> >> <svg>
>> >> >>     <segments>
>> >> >>    </segments>
>> >> > 
>> >> >    I suggest you fix it by moving the non-SVG elements 
>> >> > out of the SVG namespace:
>> >> >    <svg xmlns:prad="http://prad.org/">
>> >> >         <prad:segments>
>> >> >         </prad:segments>
>> >> >    </svg>
>> >> > 
>> >> > 
>> >> > 
> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: 
> batik-users-unsubscribe@xmlgraphics.apache.org
>> >> > For additional commands, e-mail: 
>> > batik-users-help@xmlgraphics.apache.org
>> >> > 
>> >> > 
>> >> > 
>> >> 
>> >> -- 
>> >> View this message in context: 
>> > http://www.nabble.com/getting-dom-from-svg-file-
>> >> tf2120596.html#a5860806
>> >> Sent from the Batik - Users forum at Nabble.com.
>> >> 
>> >> 
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: 
> batik-users-unsubscribe@xmlgraphics.apache.org
>> >> For additional commands, e-mail: 
> batik-users-help@xmlgraphics.apache.org
>> >> 
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail: 
> batik-users-help@xmlgraphics.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context: 
> http://www.nabble.com/getting-dom-from-svg-file-
>> tf2120596.html#a5920621
>> Sent from the Batik - Users forum at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a5938589
Sent from the Batik - Users forum at Nabble.com.


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


Re: getting dom from svg file

Posted by th...@kodak.com.
Hi Prad,

     Do not send the same message multiple times to the list.

prad <pr...@yahoo.co.in> wrote on 08/22/2006 03:20:03 AM:

> Now i have decided to parse svg file as simple xml dom and change the
> namespace of few elements and then use this modified file to create
> SVGDOM.......does it works....if yes,

   Yes, this will work.  Since you are supposed to ignore the 
elements you could also remove them (this is simpler).

> how do i change or move elements to different namespace...

   I would suggest using the following to locate the problem elements: 
        Element.getElementsByTagNameNS(String namespace, String tagName)

   Then the simplest thing to do is remove them from the DOM:

        Element problem = nodeList.get(i);
        problem.getParentNode().removeChild(problem);

   Moving them to another namespace is a little tricker.  First
you need to create a new element in the new namespace:

        Element newElem = doc.createElementNS(newNamespace, 
problem.getTagName());
        // Then copy the attributes from the problem node to the new node.
        NamedNodeMap nnm = problem.getAttributes();
        int len = nnm.getLength();
        for (int i=0; i<len; i++) {
                Attr a = (Attr)nnm.get(i);
                Attr newAttr = (Attr)doc.importNode(a, true);
                newElem.setAttributeNode(newAttr);
        }

        Then you need to replace the problem element with the
new Element:

        problem.getParentNode().replaceChild(newElem, problem);

        This get's a bit more complex if the elements that need to
be moved may have children that also need to be moved... You basically
need to walk the problem element's children running the above code
on each of them an appending them to 'newElem'.

   (The above is untested 'psuedo code')
   Good luck!

> thomas.deweese wrote:
> > 
> > Hi Prad,
> > 
> > prad <pr...@yahoo.co.in> wrote on 08/18/2006 02:15:56 AM:
> > 
> >> Thanks for the suggestion,but am not supposed to change svg file or 
> > change
> >> namespace wat i have to do is to handle such elements by ignoring 
them
> > 
> >     I will _very_ strong recommend that you fix the files.
> > Changing tools to work around broken files is 100% always the
> > wrong answer to the problem.
> > 
> >     That said you can try creating a subclass of 
> > batik.dom.svg.SVGDOMImplementation that replaces the 
> > createElement & createElementNS methods. 
> > 
> >     This is about all the help I'll give on this topic
> > as I consider this the totally wrong way to approach 
> > the problem.
> > 
> >     Good luck!
> > 
> >> thomas.deweese wrote:
> >> > 
> >> > Hi Prad,
> >> > 
> >> > prad <pr...@yahoo.co.in> wrote on 08/17/2006 06:06:13 AM:
> >> > 
> >> >> Am finding difficult to get the dom for a svg file. 
> >> > 
> >> >    Actually it looks like you are getting DOM fine for
> >> > SVG files.  It is files that look a little like an
> >> > SVG file but aren't that causing you problems (as they should).
> >> > 
> >> >> But If the svg file contains other tags like
> >> > 
> >> >    This is not a valid SVG file:
> >> >> <svg>
> >> >>     <segments>
> >> >>    </segments>
> >> > 
> >> >    I suggest you fix it by moving the non-SVG elements 
> >> > out of the SVG namespace:
> >> >    <svg xmlns:prad="http://prad.org/">
> >> >         <prad:segments>
> >> >         </prad:segments>
> >> >    </svg>
> >> > 
> >> > 
> >> > 
---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: 
batik-users-unsubscribe@xmlgraphics.apache.org
> >> > For additional commands, e-mail: 
> > batik-users-help@xmlgraphics.apache.org
> >> > 
> >> > 
> >> > 
> >> 
> >> -- 
> >> View this message in context: 
> > http://www.nabble.com/getting-dom-from-svg-file-
> >> tf2120596.html#a5860806
> >> Sent from the Batik - Users forum at Nabble.com.
> >> 
> >> 
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: 
batik-users-unsubscribe@xmlgraphics.apache.org
> >> For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> >> 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: 
http://www.nabble.com/getting-dom-from-svg-file-
> tf2120596.html#a5920621
> Sent from the Batik - Users forum at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Re: getting dom from svg file

Posted by prad <pr...@yahoo.co.in>.
Hi Thomas,
Now i have decided to parse svg file as simple xml dom and change the
namespace of few elements and then use this modified file to create
SVGDOM.......does it works....if yes how do i change or move elements to
different namespace...

regards prad

thomas.deweese wrote:
> 
> Hi Prad,
> 
> prad <pr...@yahoo.co.in> wrote on 08/18/2006 02:15:56 AM:
> 
>> Thanks for the suggestion,but am not supposed to change svg file or 
> change
>> namespace wat i have to do is to handle such elements by ignoring them
> 
>     I will _very_ strong recommend that you fix the files.
> Changing tools to work around broken files is 100% always the
> wrong answer to the problem.
> 
>     That said you can try creating a subclass of 
> batik.dom.svg.SVGDOMImplementation that replaces the 
> createElement & createElementNS methods. 
> 
>     This is about all the help I'll give on this topic
> as I consider this the totally wrong way to approach 
> the problem.
> 
>     Good luck!
> 
>> thomas.deweese wrote:
>> > 
>> > Hi Prad,
>> > 
>> > prad <pr...@yahoo.co.in> wrote on 08/17/2006 06:06:13 AM:
>> > 
>> >> Am finding difficult to get the dom for a svg file. 
>> > 
>> >    Actually it looks like you are getting DOM fine for
>> > SVG files.  It is files that look a little like an
>> > SVG file but aren't that causing you problems (as they should).
>> > 
>> >> But If the svg file contains other tags like
>> > 
>> >    This is not a valid SVG file:
>> >> <svg>
>> >>     <segments>
>> >>    </segments>
>> > 
>> >    I suggest you fix it by moving the non-SVG elements 
>> > out of the SVG namespace:
>> >    <svg xmlns:prad="http://prad.org/">
>> >         <prad:segments>
>> >         </prad:segments>
>> >    </svg>
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail: 
> batik-users-help@xmlgraphics.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context: 
> http://www.nabble.com/getting-dom-from-svg-file-
>> tf2120596.html#a5860806
>> Sent from the Batik - Users forum at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a5920621
Sent from the Batik - Users forum at Nabble.com.


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


Re: getting dom from svg file

Posted by th...@kodak.com.
Hi Prad,

prad <pr...@yahoo.co.in> wrote on 08/18/2006 02:15:56 AM:

> Thanks for the suggestion,but am not supposed to change svg file or 
change
> namespace wat i have to do is to handle such elements by ignoring them

    I will _very_ strong recommend that you fix the files.
Changing tools to work around broken files is 100% always the
wrong answer to the problem.

    That said you can try creating a subclass of 
batik.dom.svg.SVGDOMImplementation that replaces the 
createElement & createElementNS methods. 

    This is about all the help I'll give on this topic
as I consider this the totally wrong way to approach 
the problem.

    Good luck!

> thomas.deweese wrote:
> > 
> > Hi Prad,
> > 
> > prad <pr...@yahoo.co.in> wrote on 08/17/2006 06:06:13 AM:
> > 
> >> Am finding difficult to get the dom for a svg file. 
> > 
> >    Actually it looks like you are getting DOM fine for
> > SVG files.  It is files that look a little like an
> > SVG file but aren't that causing you problems (as they should).
> > 
> >> But If the svg file contains other tags like
> > 
> >    This is not a valid SVG file:
> >> <svg>
> >>     <segments>
> >>    </segments>
> > 
> >    I suggest you fix it by moving the non-SVG elements 
> > out of the SVG namespace:
> >    <svg xmlns:prad="http://prad.org/">
> >         <prad:segments>
> >         </prad:segments>
> >    </svg>
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: 
http://www.nabble.com/getting-dom-from-svg-file-
> tf2120596.html#a5860806
> Sent from the Batik - Users forum at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Re: getting dom from svg file

Posted by prad <pr...@yahoo.co.in>.
Hi Thomas,
Thanks for the suggestion,but am not supposed to change svg file or change
namespace
wat i have to do is to handle such elements by ignoring them

thomas.deweese wrote:
> 
> Hi Prad,
> 
> prad <pr...@yahoo.co.in> wrote on 08/17/2006 06:06:13 AM:
> 
>> Am finding difficult to get the dom for a svg file. 
> 
>    Actually it looks like you are getting DOM fine for
> SVG files.  It is files that look a little like an
> SVG file but aren't that causing you problems (as they should).
> 
>> But If the svg file contains other tags like
> 
>    This is not a valid SVG file:
>> <svg>
>>     <segments>
>>    </segments>
> 
>    I suggest you fix it by moving the non-SVG elements 
> out of the SVG namespace:
>    <svg xmlns:prad="http://prad.org/">
>         <prad:segments>
>         </prad:segments>
>    </svg>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/getting-dom-from-svg-file-tf2120596.html#a5860806
Sent from the Batik - Users forum at Nabble.com.


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


Re: getting dom from svg file

Posted by th...@kodak.com.
Hi Prad,

prad <pr...@yahoo.co.in> wrote on 08/17/2006 06:06:13 AM:

> Am finding difficult to get the dom for a svg file. 

   Actually it looks like you are getting DOM fine for
SVG files.  It is files that look a little like an
SVG file but aren't that causing you problems (as they should).

> But If the svg file contains other tags like

   This is not a valid SVG file:
> <svg>
>     <segments>
>    </segments>

   I suggest you fix it by moving the non-SVG elements 
out of the SVG namespace:
   <svg xmlns:prad="http://prad.org/">
        <prad:segments>
        </prad:segments>
   </svg>


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