tool to view XML as a tree? [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Is there any java based tool to view the XML file in the form of binary/ternary tree?
I need a pictorial view of tree.. in the form of nodes and edges.. like a graph..
please help me

If you have any XML/XSLT skills you could transform your XML to SVG. This method would allow you to draw anything you want. See an example here. Once you have the SVG file you can upload it into Google docs or view it in Photoshop or embed it in an html document.

Eclipse (IDE) www.eclipse.org
The XML editor also has a Design view. This view has the following features:
List item
The XML file is represented simultaneously as a table and a tree. This helps make navigation and editing easier.
Content and attribute values can be edited directly in the table cells, while pop-up menus on the tree nodes give alternatives that are valid for that location. For example, the Add Child menu item will list only those elements from a DTD or XML schema which would be valid children at that point (as long as grammar constraints are on).

Take a look at JUNG, http://jung.sourceforge.net/. I've used that toolkit to create an XPath visualizer, which was kind of fun. Don't remember if there was a ready XML to tree example, or not, though.

XML Spy would be good, but it's not free.
You can open XML in any browser and see it rendered as a hierarchy.

Related

how to append data in an existing pdf? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm trying to add some data to a PDF with iText 7 in a Java application.
I don't succeed in opening the pdf in append mode. I looked for some solutions online but all concerned iText5 (and use classes that doesn't exist any more.)
What can I do?
It depends on what you want specifically:
merge two documents:
https://developers.itextpdf.com/content/itext-7-examples/itext-7-merging-pdf-documents
add content at the end of a document:
Similar to before, you could create a new document (to a byte output stream), and merge the two together
add content to an existing page:
Hard to do, since that typically requires re-layout of the document, which no PDF-engine can currently do.
fill in forms in the document:
https://developers.itextpdf.com/content/itext-7-examples/itext-7-form-examples
add an attachment to the document:
https://developers.itextpdf.com/examples/miscellaneous/clone-embedded-files
extra (3):
Adding content to a PDF, in the middle of existing content is extremely hard.
To understand why, here is some information on how PDF documents are built internally:
PDF documents contain instructions for a viewer to render, rather than plain text
instructions and their arguments are grouped in 'objects'
objects can be compressed to reduce file size
a PDF document keeps an internal index of all of these objects, this is called the XREF table
the index inside a PDF document uses byte-offsets to tell a renderer where (in the file) an object can be found
Suppose you want to change (or add) something.
You'd mess up all the byte-offsets in the XREF. No viewer would be able to find any object again.
Then there is the fact that the PDF does not contain layout information. If you added something new, and existing content would need to move, you need layout information (what objects make a sentence? which sentences make a paragraph?). Only by having layout information can you sensibly re-layout the document.

XML Document Parsing in Java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need to parse an XML document in java for a web service I'm making, and save the contents of it.
I need to save the name of the tags, if the tag has attributes save the attributes, and then save the data within those tags. These three items will be inserted into a database table with the three columns tags, attributes, and data.
I'm using the following java libraries:
javax.xml.parsers.DocumentBuilder
javax.xml.parsers.DocumentBuilderFactory
org.w3c.dom.Document, org.w3c.dom.NodeList
org.xml.sax.InputSource.
Any help would be much appreciated.
DISCLAIMER: I don't want to plagiarize so I didn't include code but included links to other tutorials that are VERY helpful to this topic.
First, you should read w3c dom's java API because it tells you a lot of useful functions that are very related to your question.
Second, this website contains a useful tutorial that's easy to understand and it contains the necessary information for you to get the attributes of tags.
Third, this website gives you info on how to get tagName when you are looping through elements.
Fourth, you should always read related API, google, and then post a question if you are have no clue after a LONG period of time.
Lastly, you should post a difference question or research on database FIRST before asking that question here. This question should only be about XML Document Parsing in Java.
We are not supposed to help you do anything so the API is the best help for you (and google).
API: https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/package-summary.html

How to convert XML to Object in Groovy and insert into MongoDB collection? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I have large number of various XML documents I need to ingest into MongoDB using Groovy.
Now I have problem that there isn't any generic way to convert any XML into Object based on some simple rules, at least I can't find any.
What I would like to do, take any random XML, and create object which will contain timestamps, integers, strings as well maps, basically it would be all decomposed based on the XML structure.
For example, to do it in PHP, is to convert it into JSon, and from JSon into Object. Now I would like to add some converters that for certain elements in XML I would run little routine to e.g. convert timestamps, and I would like to also map certain values as integers, intervals and so on.
I looked on XStream but it requires me to create Object definition for each XML, otherwise it throws "unresolvable" exception.
Is there better way than to do it manually? In Groovy iterating thru XML is not really very fast, I would prefer to use some Java library to do it, even if it's quite of dynamic style operation.
Analogue tool for logfiles is called LogStash. It can have embedded JRuby evaled code in config to convert certain fields of logfiles like timestamps and ingest them into elastic search as object documents.
There is org.json:json to convert XML to JSON and mongo can deal with this on it's own. Of course this all works with plain java, but is shorter in groovy... alot
#Grapes([#Grab('com.gmongo:gmongo:1.3'),#Grab('org.json:json:20140107')])
def json = org.json.XML.toJSONObject('''\
<?xml version="1.0"?>
<root>
<of>
<all>Evil</all>
</of>
</root>''')
def db=new com.gmongo.GMongo().getDB("gmongo")
db.test.remove([:])
db.test << com.mongodb.util.JSON.parse(json.toString())
db.test.find().each{ println it}

Replacing XML Nodes in Java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an XML document in a foreign language and another XML document in English. I am trying to replace some nodes in the foreign document with nodes from the English document and export the document.
I have been working on this for days now and have tried countless things form importing both documents into text with a Scanner, BufferedReader, etc. with no good results.
I'm at a loss on what else I can try. I have searched for days and have nothing. Maybe what I'm trying to do cannot be done although it seems simple enough. Any help/direction would be appreciated.
Put them into DOM objects, then use XPATH to locate and select nodes, to copy values between them.
Depending on what you need to replace and what you mean by "export", I would use an XML parser like SAX using the following algorithm
For each node that you read
Replace attributes or text as necessary
Write it out to the the a new XML file
There are many tutorials out there on how to use SAX, such as this one: How to parse XML using the SAX parser
If the "replacements" you need to do are very straightforward like "all <tag> objects under <parent-tag>" then maybe building the DOM and using XPath would work, but if your replacements are very arbitrary and unstructured then I'd go with parsers.

Photo identity card generation API for java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I am developing a small scale patient record program. One of the functionalities they need is to generate Photo ID Card by fetching a bunch of rows from the DB. I have very little experience in jasper reports. I am looking for a API which can help generate these ID cards. For example I will feed the API a design template and a the data result set and it will do the job.
If you are suggesting jasper and iReport then please guide me through the process of solving the problem. and if there are no API then can you please show me a way where i can achieve similar result?
Thanks in advance.
The problem was solved using jasper reports itself. I just had to set up a proper layout for a single ID. Now this is important only 1 layout is needed to be designed. And then you need to specify a query that will return the list of rows to be used to generate the ID cards.
Your query will return multiple rows so you need them arranged one after another, its so common that you want 8ID cards in 1 A4 page (2columns). For this case right click the report -> properties set columns to 2 and print order horizontal. Make sure your model stays within a single column

Categories

Resources