How to do fo to pdf transform without accessing w3c? - pdf

Is it possible to do fo to pdf transform via java.xml.transform without accessing www.w3.org? There are, of course, references to this website in the schema, etc. Example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions">
Is there a way to move files to a local machine to avoid going to the w3 server? I know this isn't ideal, but the ip accessing w3 is currently getting http403 back so I need a temporary workaround while we address the larger problem. Thanks for any ideas.

The things that look like attributes that start with xmlns are namespace declarations. Neither your XSLT processor nor your XSL formatter will access the W3C servers because of the namespace declarations.
Namespaces are just a way to disambiguate elements that have the same local name. In your case, the http://www.w3.org/1999/XSL/Transform namespace URI lets the XSLT processor recognise the elements (and some attributes) that are significant for XSLT processing, and the http://www.w3.org/1999/XSL/Format namespace URI lets the XSL formatter recognise the elements that are defined by the XSL specification.
The URI that is the value of the namespace declaration doesn't need to be a resolvable URL. But for your XSLT and XSL-FO processing to work, they do have to be those URLs that you are using.
I would refer you to the Namespaces in XML specification, but I'm having a similar 403 problem myself. This tutorial from xml.com explains namespaces: https://www.xml.com/pub/a/1999/01/namespaces.html

Related

Taking control of WSDL/XSD from WCF-SVCUtil (Annotations, Schema Namespaces, and Schema Locations)

In the WSDL that is generated from a WCF service, there are a few problems that I'd like to take control of a little more. First, is there a way to add annotations to the xsd files generated with the WSDL without using surrogates?
I've taken care of adding annotations to the WSDL itself thanks to the following articles:
http://msdn.microsoft.com/en-us/library/system.servicemodel.description.iwsdlexportextension.aspx"
http://www.codeproject.com/Articles/29980/Exporting-Annotations-from-WCF
I was able to add annotations to data members through agillior, however they used surrogates which I would rather not use.
http://agilior.pt/blogs/bruno.camara/archive/2006/10/01/6.aspx
I would use Thoranin's solution except I want to apply the annotations to data members not parameters
http://thorarin.net/blog/post/2010/08/08/Controlling-WSDL-minOccurs-with-WCF.aspx
Second, I want to explicitly name the namespaces for the xsd files generated from the WSDL. I was able to take control over the namespace of the wsdl using the ServiceBehaviorAttribute: [ServiceBehavior(Namespace="http://mysite.com/HelloWorld")]
but unfortunately I can't find an easy way to specify the namespace of the xsd files :(, is there a simple way to do this/can you point me in the right direction?
-edit-Well I was being silly on the second request. I had forgotten to set the namespaces for my wcf files which is what maps to the xsd namespaces. My bad :) .
Lastly, when the wsdl imports an xsd, it uses a path similar to http://localhost:8080/HostDevServer/HelloWorldService.svc?xsd=xsd0
which seems to break the wsdl2java ant script by apache. I can go in and manually change them to the local files but it's just such a pain :). Is there any way to have the files generated and then have a local reference like:
HelloWorldService.xsd,HelloWorldService1.xsd etc?
Any feedback would be appreciated.
WCFExtras ftw:
I decided that instead of having my own attributes and classes put documentation/annotation into the WSDL and XSD files I would just give into the hype and let WCFExtras take care of it. That being said I do wish that the Xml comments would be split into different lines instead of having them all on the same line. (Just to make reading the xml files easier). Plus WCFExtras takes care of the surrogate problem perfectly :) !
Ended up writing a program to solve the third issue. It pretty much grabs the metadata files using svcutil then goes in and finds all the imports, and reassigns them to the files downloaded based of off the namespaces.

can XInclude be used on stream input?

I would like a portable solution to creating a multiply nested XML document using XInclude. I am using <xi:include href="foo.xml"> elements and taking the input from a stream. So far this fails (I am using XOM which has its own XIncluder) which reports it cannot find the base URL for the href. I am wondering if this is a general problem (see XercesDOMParser and XIncludes ). If so are there general workarounds?
A relative URI like foo.xml is useless without the context of a base URI with which to work out that e.g. if the base URI is http://example.net/bar/baz.xml then the absolute URI of the resource is http://example.net/bar/foo.xml.
This base URI can come from:
The URI that the XML in question came from (clearly not applicable to a stream alone).
A URI passed to a parser by mechanisms specific to it.
xml:base
Means specific to a given XML application (not advisable, but sometimes necessary for compatibility with other formats, e.g. the <base /> element in XHTML duplicates xml:base unnecessarily and with less flexibility, but is required for compatibility with HTML4.01 and earlier).

shorten type names in struts config

i have this really big struts-based web app that i have to maintain, and the package names follow this convention (more or less):
[app-name].[module].[module-variant].[layer].[activity].[activity-variant]
the jsp files are arranged in a similar fashion:
Web-Content/jsp/[app-name]/[module]/[module-variant]/[activity]/[activity-variant]
so when i have to add another action mapping to the struts-config.xml i have to write
again this :
[app-name].[module].[module-variant].[layer]
and this for the foward:
/jsp/[app-name]/[module]/[module-variant]/
with a couple of action mappings, the struts-config.xml file gets really noisy, and its hard to understand the action fowards at a glance.
So, is there any way to specify globaly a package name so i dont have to write the fully qualified name for each action class in the struts-config.xml ?,
for example in a hibernate mapping you can specify "package" and "schema" and refer to the table/classes with their short name
btw im using struts 1.3
As far as I know there is no way to do that; Struts expects fully qualified class name for the ActionForms, Actions etc.
What you could do is write a "your's special" struts-config.xml file with global names and stuff, then pass it through a tool at build time to re-generate the actual struts-config.xml that Struts is expecting.
You could also have the struts-config.xml file generated entirely at build time by placing some "annotations" (not Java 5 annotations :D) in the Action classes using XDoclet.
Or you could resort to a nice formatting of the xml and just get used to it.

Objective-C libraries for XML Parsing

I would like to know some libraries in objective-C for xml parsing. I think it is a very common need, but I found limited resources for handling this task:
Google Code projects: TouchCode (TouchXML)
NSXMLParser
What is your best solution to work with XML in objective-C language? Please advice.
What is the solution that you have used for your product?
NSXMLParser is a stream-oriented class; you set it up and get delegate callbacks when it detects something. Usually this is not what you want to do, but can be much faster and lower memory.
TouchXML will parse the XML itself using libxml, and create an object tree for the entire XML structure. This allows you to easily access the contents of the XML tree, using manual traversal methods or basic XPaths (more sophisticated XPath support is planned).
It serves a narrow purpose, but if your goal is to parse untidy HTML, you might want to try a static library I started called TagScraper. It doesn't handle many/most XML/HTML entities correctly, but it could be pretty easily patched to. URL: http://github.com/searls/TagScraper
Its value is that it provides a simple XPath mechanism that hides the tidying/querying/assembling for you, and then it provides the parsed elements & attributes in a tree-like data structure of Tag.h nodes.

Creating bindable classes from WSDL for Flex 3

Two of our apps are web applications with a Flex 3 front end and a SOAP-style WCF back end. To communicate with the back end, I generate web service client classes through Flex Builder 3. Everything's functional, but maintaining those generated classes has been quite annoying, and I'm looking for a better way to do things (without having to do a major rewrite, of course). Here's the problems:
I use Flex libraries to manage components shared among applications. Some of them are dependent on the generated classes, so I need the WSDL-generated classes in their own library. Flex Builder 3, however, only generates the classes for a Flex application, so I have to generate the files in the application's source tree, then manually move the files every time. This also introduces strange side-effects with the way that Eclipse manages source code (why can't it just monitor the FS like other IDEs do?).
We use data binding in the MXML to declaratively tie data to the UI. I like data binding. Unfortunately, the classes in the WSDL-generated code do not support binding. Therefore, I opted to create a program to alter the ActionScript classes, adding [Bindable] metadata to them. This has to be run every time we regenerate the code.
Flex has a very nasty bug, known about at least since March, which still hasn't been fixed: http://bugs.adobe.com/jira/browse/SDK-19811. I recently discovered this, because it was double-encoding some XML characters like < and & into < and &. Therefore, I also had to add a workaround for that to the ActionScript manipulation program.
The WSDL-code generator in Flex Builder creates a String, Boolean, Int, and other classes which are built-in types! We're always having to delete these source files to prevent the Flex compiler from sometimes balking.
It seems unlikely to me that everyone is just putting up with these issues. There must be some alternative way of generating web service proxy classes for Flex that others are employing. Since I'm time-prohibited from making the communication layer RESTful and rewriting the front end in Silverlight, what do you suggest?
You can use one of several mechanisms to read the WSDL into a program and generate whatever flex code you need.
You can use one of the two ServiceDescription classes to read in a WSDL and examine its contents in terms of an object model;
You can use T4 Templates in Visual Studio with a bit of custom work to expose the WSDL to the template (possibly through the ServiceDescription class, as above)
You can use XSLT to transform the WSDL into the code you'd like
You can write some standalone program to read the WSDL (as XML or an object model) and just emit the text you want for your proxy code.
The bottom line is that, if you're having problems with the automation tools, then there are practical ways of creating your own.
Unfortunatly Flex 3 code generation from WSDL lacks from the Bindable tag, and it is a nightmare to handle that problem manually... especially if you have a complex scenario with lots of Types.
You could just add the tag manually and remove the "generated.webservices" from all variable declarations in order to make the code compile... and then you have another problem:
What if i have to generate de code again? Either i do everything again... or i will have a bunch of runtime only detected bugs...
I used ANT to a small trick:
Add Bindable to all classes;
Remove the full namespace from all variable declarations;
<target name="updateGeneratedCode" >
<replace dir="PATH TO YOUR GENERATED CODE">
<include name="**/*.as"/>
<replacetoken>public class</replacetoken>
<replacevalue><![CDATA[[Bindable]public class]]></replacevalue>
</replace>
<replace dir="PATH TO YOUR GENERATED CODE" value=":">
<include name="**/*.as"/>
<replacetoken>:generated.webservices.</replacetoken>
</replace>
</target>
Note: the replace token ":generated.webservices." may be different in your case, so you may want to replace it by your generated namespace.
It is working for me so far.
Hope it helps someone!
Antonio Inacio