Drupal Views: Generate xml file - php

Is there a views plugin that I can use to generate a xml file? I would like something that I could choose the fields I would like to be in the xml and how they would appear (as a tag or a attribute of the parent tag).
For example: I have a content type Picture that has three fields: title, size and dimensions. I would like to create a view that could generate something like this:
<pictures>
<picture size="1000" dimensions="10x10">
<title>
title
</title>
</picture>
<picture size="1000" dimensions="10x10">
<title>
title
</title>
</picture>
...
</pictures>
If there isn't nothing already implemented, what should I implement? I thought about implementing a display plugin, a style, a row plugin and a field handler. Am I wrong?
I wouldn't like do it with the templates because I can't think in a way to make it reusable with templates.

A custom style plugin is definitely capable of doing this; I whipped one up to output Atom feeds instead of RSS. You might find a bit of luck starting with the Views Bonus Pack or Views Datasource. Both attempt to provide XML and other output formats for Views data, though the latter was a Google Summer of Code project and hasn't been updated recently. Definitely a potential starting point, though.

You might want to look at implementing another theme for XML or using the Services module. Some details about it (from its project page):
A standardized solution for building API's so that external clients can communicate with Drupal. Out of the box it aims to support anything Drupal Core supports and provides a code level API for other modules to expose their features and functionality. It provide Drupal plugins that allow others to create their own authentication mechanisms, request formats, and response formats.
Also see:
http://cmsproducer.com/generate-how-to-drupal-node-XML-XHTML

In Drupal 8 the Services module is now part of core (RESTful Web Services). This will allow you to provide any entity in xml or json. Also with views.
Read more here: https://drupalize.me/blog/201401/introduction-restful-web-services-drupal-8

There is a somewhat old description of this process on the Drupal forums. It references Drupal 4.7 and 5.x. I suspect the steps for 5.x would be same technique if not same code for Drupal 6.

if you use drupal 7 and a higher version of it you can use views data export module for export as xml,xls,...
https://www.drupal.org/project/views_data_export

Related

Convert PDF to HTML version 3.2 with images and html file in a folder

I hope you are doing well.
I need to know about a PHP library that converts a PDF file having images as well to be converted in a HTML file with the following features that the library can do.
HTML file needs to be of version 3.2 compatible
Save the images in PDF file having .jpg extension
Correct font from PDF needs to be used in the HTML file.
A result folder that contains the images and html file in one folder
I have tried most of the PHP libraries but most of the PHP libraries are NOT doing my needed tasks.
Please, help let me know about a library that do all the above 4 requirements (image attached for reference)
Waiting for your kind responses.
Thanks
I am not very sure, But here is a library in PHP I found.
Here
Try this:
http://www.pdfaid.com/pdf-to-html.aspx
Or this:
http://webdesign.about.com/od/pdf/tp/tools-for-converting-pdf-to-html.htm
Or this...
http://www.pdfconvertonline.com/pdf-to-html-online.html
There are plenty of options available to you, the secret is to use a new fangled thing called a Search Engine, such as a Bing or a Google.
you will also do well to research on Stack Overflow before asking your question:
1) HTML 3.2 wes superceeded in 1997, this is very nearly twenty years ago, why on eart are you still needing a comparatively ancient technology when there are far better improvements available such as XML HTML, HTML 4.01 and HTML5.
2) Please read How can I extract embedded fonts from a PDF as valid font files?
3) Also to extract images you can use:
http://www.makeuseof.com/tag/extract-images-pdf-files-save-windows/
but again, there are several options available to you if you care to look for them.
You seem to imply a fundamental misunderstanding about HTML; there are several different ways of getting any desired result with HTML. You have a PDF file and you want it to look a certain way, this look depends on the browser you are looking at it on. For example if you use a PDF to HTML converter as linked above you will very probably find that the output will look different on Internet Explorer 7 versus on Firefox versus Internet Explorer 10. There is no one way of writing output on HTML or with CSS.
If you want a custom built library to do your specific task then you will need to employ a professional to do it, or you will need to code it yourself. This obviously should be charged to the client for requiring a technology that is extremely outdated. You can probably search github for a similar library (the one linked by CK Khan looks like what you're after) and then fork it and make your own variation for your needs. I very much doubt anyone is going to put time into developing a system to output HTML 3.2 from a PDF, and even less likely to develop this system for free and to your exact specifications.
It also appears that you can not directly incorporate font families into the <font> tag in HTML 3.2, only being able to edit size and colour of fonts. You can use CSS1 font-family to show font families. See here.

How would one create a Drupal-based Genealogy Application?

I want to use Drupal for building a Genealogy application. The difficulty, I see, is in allowing users to upload a gedcom file and for it to be parsed and then from that data, various Drupal nodes would be created. Nodes in Drupal are content items. So, I'd have individuals and families as content types and each would have various events as fields that would come from the gedcom file.
The gedcom file is a generic format for genealogy information. Different desktop applications take the data and convert it to a proprietary format. What I am not sure about how to accomplish is to give the end user a form to upload their gedcom file and then have it create nodes, aka content items, with Drupal. I can find open source code to parse a gedcom file, using python, or perl, or other languages. So, I could use one of these libraries to create from the gedcom file output in JSON, XML, CSV, etc.
Drupal is written in PHP and another detail of the challenge is that for the end user, I don't want to ask him/her to find that file created in step one (where step one is the parse and convert of the gedcom file) and upload that into Drupal. I'd like to somehow make this happen in one step as far as the end user sees. Somehow I would need a way to trigger Drupal to import the data after it is converted into JSON, or XML or CSV.
I am not personally familiar with Drupal. But I do know there already is a fairly advanced program written for Drupal called Family Tree that is a project at Drupal.org.
You might want to check that project out, or even better, contribute to it and improve it.
Disclaimer: I have no connection at all to the project, and I've never even tried the module. I just happen to be aware of it.
You'll need create a specific module (or search for an existent one) that gets the gedcom file and generates the nodes. It would be easy for the user (just one file upload).
There have been some genealogy websites built on Drupal. The best one I've seen is https://ancestry.sandes.uk/, which was announced at Functional Drupal 7 Family History Website in the Genealogy Discussion Group. I've launched a project to build a multi-user, multi-family-tree website on Drupal at www.greatalbum.net, based on Drupal7+OG. I discuss it here and here.
To be able to upload a GEDCOM file, you will need a GEDCOM module to do the work. I found this GEDCOM Sandbox Module based on D8, but it's still very early stages, and the code is currently missing. I've contacted the author, skybow, and he's going to restore the code. I will probably hire someone to develop the module for the GreatAlbum site, but it will be on D7 for now.

Online user guide plus PDF download

At the moment I am managing my user guide using Microsoft Word 2003 and am converting it to a PDF file that can be downloaded from website plus is included by product installer.
I would like to move to a mechanism that achieves the following:
Generates PDF file with clickable TOC and front page
Generates HTML5 compliant output per chapter/section but without HTML skeleton
Generates JSON TOC for user guide (chapter/section outline)
I would like to package the PDF file with the distributed product.
I would like to create some simple PHP scripts that generate HTML pages with a context sensitive TOC (showing sections of current chapter) plus showing the relevant documentation.
I have no issues with developing the PHP scripts to achieve this, but I would like to know how I can generate the above outputs. I would preferably like to type documentation using an off-the-shelf GUI. I am happy to write XSLT2 stylesheets to perform any necessary conversions.
To give people an idea of what I am after:
Current PDF manual: http://rotorz.com/tilesystem/user-guide.pdf
API documentation which is generated using custom XSLT2 stylesheets into a bunch of "incomplete" HTML files, with a JSON TOC which is then brought together by PHP: http://rotorz.com/tilesystem/api
As you navigate through my API documentation you will notice that the TOC on the left is context sensitive. I would like my user guide to work in a similar way.
Is there a free alternative to Prince: http://www.princexml.com/ for paged media CSS?
After spending quite some time reading into lots of variations I have come across a potential solution...
Create a very simple "static" CMS using PHP and http://aloha-editor.org for my WYSIWYG editor. Possibly using https://github.com/chillitom/CefSharp to embed the editor straight into a more relevant GUI.
Convert the HTML5 pages into PDF using "wkhtmltoxdoc" with custom cover, header and footer .html files. Plus generates a TOC page automatically.
"wkhtmltoxdoc" also generates an XML TOC which can easily be converted to JSON.
I am still experimenting with "wkhtmltoxdoc" but it seems pretty good! Unless of course there is an even easier solution...
ADDED:
It seems that my TOC file will need to be a mixture of manually written and automatically generated. Something along the lines of the Eclipse TOC schema will suffice where a simple XSLT stylesheet can automatically fill in the blanks by grabbing H1-6 tags plus adding unique identifiers for hash links.
This TOC can thus be consumed by XSLT2 stylesheets and then finally converted to JSON for consumption by PHP scripts.
Mock-up extract for my existing documentation:
<?xml version="1.0" encoding="UTF-8"?>
<toc>
<topic label="Introduction" href="introduction.html"/>
<topic label="Getting Started">
<topic label="Installation" href="getting-started/installation.html"/>
<topic label="User Interface" href="getting-started/ui/index.html">
<topic label="Menu Commands" href="getting-started/ui/menu-commands.html"/>
<topic label="Tile System Panel" href="getting-started/ui/tile-system-panel.html"/>
<topic label="Brush Designer" href="getting-started/ui/brush-designer.html"/>
</topic>
<topic label="User Preferences" href="getting-started/user-preferences.html"/>
</topic>
<topic label="Creating a Tile System" href="creating-a-tile-system">
<!-- ... -->
</topic>
</toc>
Reference to Eclipse documentation:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_help_toc.html
After a lot of research and experimentation I have decided to use DITA (Darwin Information Typing Architecture). For me the nicest thing about DITA is that it is topic based which makes the documentation modular and reusable.
The DITA schema is relatively simple and good XML editors provide useful insight into the available elements and attributes.
DITA documents can be combined for purpose using DITAMAP's. For example one might choose to distribute a "Quick Start Guide" which encompasses a minimal amount of information whilst a full blown "User Guide" will contain far more detail. The beauty is that the same information can be reused for both documents; plus the documents can be outputted to a number of delivery formats:
XHTML (single file or chunked)
PDF
Docbook
The process of transforming the output into the delivery format is easily handled using the DITA Open Toolkit (aka DITA-OT). This toolkit is available from: http://dita-ot.sourceforge.net which is installed simply by extracting the provided archive. The toolkit can be accessed easily by running startcmd.bat (on Windows) or startcmd.sh (Unix-like systems).
Customising and branding PDF output is not an easy task. Customizing XHTML output is significantly easier but still requires knowledge of XSL transforms. Customisations can be made by creating a plugin and placing it within the plugins folder of DITA-OT. One thing that I would like to emphasise is that once customisations have been made you must invoke ant -f integrator.xml before changes will become apparent. Lack of this knowledge caused me a lot of confusion!
The generated XHTML files are very simple (which is great!) because this makes them easy to customize. Adding the HTML5 DOCTYPE is not so easy though; but for my purposes this really doesn't matter seen as though my PHP scripts only care about what's inside <body>.
I haven't been able to find any good WYSIWYG editors XML Mind seems to be a really good WYSIWYG editor that is also really easy to use. I suspect that it wouldn't be too hard to create a basic web-based solution using something like the Aloha Editor (http://aloha-editor.org).
Whilst it seems rather difficult to customise the PDF output, it seems quite easy to generate all documentation into a single XHTML page which can then be formatted using CSS, and then finally converted using wkhtmltopdf. I haven't decided on my solution yet, but at least this is a viable option for those who are unable (or don't have the time to) customise the XSL:FO stylesheets of DITA-OT.
ADDED: After some searching I found that there is an another open source alternative to DITA-OT called "Ditac" which seems a lot easier to use and produces a far nicer output. The tool is created by the creators of "XML Mind". Whilst the tool is command line based, those who use "XML Mind" can benefit from a feature rich GUI:
http://www.xmlmind.com/ditac/
Note: I left my previous answer because it may be of use to others.

how to import large xml(custom) file into wordpress

I am new to Wordpress, tried couple of plugins to import xml file. This file is quite huge. I am unable to import it. Any tutorial or suggestions?
Edit : format of the XML file is below
<articles>
<article id="1240xxxx" timestamp="April 27, 2009, 8:26 am" published="1">
<title>Theme Parks in Tenerife</title>
<pageName>theme-parks-in-tenerife-408</pageName>
<imageFile>blogthemeparkstenerife.jpg</imageFile>
<imageAlt>Theme Parks in Tenerife</imageAlt>
<content>
<p>Anyone taking a
holiday in Tenerife.
</p>
</content>
<summary>Theme Parks in Tenerife offer an alternative to the traditional beach holiday, providing entertainment for families.</summary>
<tags>
<tag>tenerife</tag>
<tag>holidays</tag>
<tag>parks</tag>
<tag>beaches</tag>
<tag>island</tag>
</tags>
</article>
So the markup is incompatible with the Wordpress import function. That leaves two other options:
Transform the XML into wordpress-compatible XML using XSLT.
Import the XML into the MySQL database. This might require transforming XML to SQL with XSLT.
Both require some understanding of wordpress internals. In the first case you will need to learn about the wordpress export markup, in the second case you will need to learn about the database scheme of wordpress posts (and tags and categories). In both cases you need to learn some XSLT, but that's a real valuable tool anyway.
A 'last resort' option would be something along the lines of parsing the XML and scripting the submission of the articles. The viability of this option depends on the ways you can 'automate' article submission in Wordpress. I know there's a way to submit articles through email, but I don't know how well that supports tags and categories.
These might not be the most pretty options, and you might be screwed anyway. But this is the least I could do.
You can parse the XML into a different format using a scripting language. I would use JQuery for familiarity [a good guide is here: http://net.tutsplus.com/tutorials/javascript-ajax/use-jquery-to-retrieve-data-from-an-xml-file/]
You could use that method to then create a HTML document which this import plugin could use: http://wordpress.org/extend/plugins/import-html-pages/
Or you could use one of the CSV importers and render the XML into a useful format for that.
If it is massive your browser/script might struggle but it should be fine.
Use the WP All Import plugin for WordPress.
WP All Import v3 was just released and it has support for huge files (100Mb and up).
Free version: http://wordpress.org/extend/plugins/wp-all-import/ (good enough unless you need to import to Custom Post Types or download images)
Paid version: http://www.wpallimport.com/

How would the conversion of a custom CMS using a text-file-based database to Drupal be tackled?

Just today I've started using Drupal for a site I'm designing/developing. For my own site http://jwm-art.net I wrote a user-unfriendly CMS in PHP. My brief experience with Drupal is making me want to convert from the CMS I wrote. A CMS whose sole method (other than comments) of automatically publishing content is by logging in via SSH and using NANO to create a plain text file in a format like so*:
head<<END_HEAD
title = Audio
keywords= open,source,audio,sequencing,sampling,synthesis
descr = Music, noise, and audio, created by James W. Morris.
parent = home
END_HEAD
main<<END_MAIN
text<<END_TEXT
Digital music, noise, and audio made exclusively with
#=xlink=http://www.linux-sound.org#:Linux Audio Software#_=#.
END_TEXT
image=gfb#--#;Accompanying image for penonpaper-c#right
ilink=audio_2008
br=
ilink=audio_2007
br=
ilink=audio_2006
END_MAIN
info=text<<END_TEXT
I've been making PC based music since the early nineties -
fortunately most of it only exists as tape recordings.
END_TEXT
( http://jwm-art.net/dark.php?p=audio - There's just over 400 pages on there. )
*The jounal-entry form which takes some of the work out of it, has mysteriously broken. And it still required SSH access to copy the file to the main dat dir and to check I had actually remembered the format correctly and the code hadn't mis-formatted anything (which it always does).
I don't want to drop all the old content (just some), but how much work would be involved in converting it, factoring into account I've been using Drupal for a day, have not written any PHP for a couple of years, and have zero knowledge of SQL?
How would I map the abstraction in the text file above so that a user can select these elements in the page-publishing mechanism to create a page?
How might a team of developers tackle this? How do-able is it for one guy in his spare time?
You would parse the text with PHP and use the Drupal API to save it as a node object.
http://api.drupal.org/api/function/node_save
See this similar issue, programmatically creating Drupal nodes:
recipe for adding Drupal node records
Drupal 5: CCK fields in custom content type
Essentially, you create the $node object and assign values. node_save($node) will do the rest of the work for you, a Drupal function that creates the content record and lets other modules add data if need be.
You could also employ XML RPC services, if that's possible on your setup.
Since you have not written any PHP for a long time, and you are probably in a hurry, I suggest you this approach:
Download and install this Drupal module: http://drupal.org/project/node_import
This module imports data - nodes, users, taxonomy entries etc.- into Drupal from CVS files.
read its documentations and spend some time to learn how to use it.
Convert your blog into CVS files. unfortunately, I cannot help you much on this, because your blog entries have a complex structure. I think writing a code that converts it into CVS files takes same time as creating CVS files manually.
Use Node Import module to import data into your new website.
Of course some issues will remain that you have to do them manually; like creating menus etc.

Categories