How To Downgrade The iOS 7 Beta Back To iOS 6 The Easy Way – ReadWrite


http://readwrite.com/2013/06/13/how-to-downgrade-from-ios-7-beta-back-to-ios-6#disqus_anchor&awesm=~ocS2CVXpn8lQfM

How To Downgrade The iOS 7 Beta Back To iOS 6 The Easy Way

How To Downgrade The iOS 7 Beta Back To iOS 6 The Easy Way

Upgrading to iOS 7 is a pretty painless process. All that’s required is an Apple Developer account and the time it takes to download the install file. Going back, however, isn’t quite so easy.

Unlike instances in the past where upgrading to Apple’s new beta OS was a one-way road – which will likely be the case again once iOS 7 is released to the world at large – you can in fact still revert back to iOS 6 if you’ve upgraded to the iOS 7 beta.

If you’re like me, you may have thrown caution to the winds by loading iOS 7 on your iPhone without much more than a vague hope that you could restore it to its prior (and fully functioning) glory. Fortunately, it’s a lot easier than various online guides are making it out to be.

Step 1: Download The Proper iOS 6 File

In order to install iOS 6, you must pick the proper version or iTunes will spit an error back at you. For the iPhone 5, you must download iOS 6.1.4. For everything else, it is iOS 6.1.3. If you use the wrong file for your device, iTunes will not allow you to restore it.

To review:

Step 2: Plug The Device Into Your Computer, Cancel The iTunes Automatic Sync Process (If It Starts)

When plugging in your smartphone back into your computer, the iPhone may begin syncing its data with iTunes. This could happen even if you had previously had it set to manual sync. This could be problematic if iTunes tries to make a new backup of your device with iOS 7.

You should cancel the sync just to be safe. While I did not let it happen with my device, having an iOS 7 backup could supersede your old backups and keep you from restoring your phone as it was in iOS 6 with all your content – apps, settings, music, photos – intact. Despite that, you should still be able to, at the very least, setup the device as a new iPhone.

Step 3: Do Not Put Your Device Into DFU Mode, Just Hit Restore

The popular notion when downgrading from iOS 7 to iOS 6 is to put you iPhone into DFU (Download Firmware Update) mode, which is Apple’s version of recovery mode for iDevices. It turns out that this is completely unnecessary and your iPhone can be downgraded without that extra effort.

To put your iPhone in DFU mode:

  • Hold down the home and power button for 10 seconds.
  • Release the power button while continuing to hold the home button for eight seconds.

(Read more: Apple’s New iOS 7: What You Need To Know Now)

This process sets up your phone automatically for a restore. It is not technically required to downgrade to iOS 6. At the same time, using DFU mode will not have any negative effect on restoring to iOS 6. You can use it if it makes you comfortable.

Once your iPhone is recognized by iTunes, simply hold the Alt/Option button on a Mac or the shift key on a Windows machine and click “Restore iPhone…” The option to choose the iOS6 .ipsw file will pop up, the same way it does when upgrading to iOS 7.

Find the proper file, click it and wait. If you don’t hit any annoying road blocks, your device should be back on the iOS 6 train. At this point, choose to restore it from a backup and pick your most recent iOS 6 backup. Hopefully, you made that backup the same day you took the iOS 7 plunge.

A Special Case: iTunes Error 3194

If you run into an error immediately following the process of the restore where iTunes says it’s verifying your iPhone’s eligibility, you might have simply downloaded the wrong iOS 6 file, noted above.

But if you’re absolutely sure you have the right file, then you may just be running into a common iTunes error. Cult of Mac detailed how to fix it.

Here’s the step-by-step breakdown:

  • Navigate to the Finder, and select Go in the menu bar
  • Click ‘Go to Folder…’
  • Type ‘/etc’ and find the ‘hosts’ file
  • Copy the ‘hosts’ file and paste it your desktop, then open it in Text Edit
  • At the very bottom of the file, find a line that reads, “74.208.105.171 gs.apple.com” and delete it
  • Drop that file back into the ‘/etc’ folder, choose replace (your Mac may ask you to authenticate the decision).
  • Go back to iTunes restore using the methods described above

Let us know in the comments if you successfully downgraded from Apple’s newest beta. And don’t hesitate to let us know if you used a different method from the one described here to downgrade from iOS 7 to iOS 6.

By Reda Bouaichi Posted in Tech, tips Tagged

How to Be Happy At Work. Short tutorial.


Then God said to Adam, “You listened to your wife and ate fruit from the tree. Cursed is the ground because of you. Through hard work you will get your food, every day of your life.”

This Adam curse continues and now – we have to work hard every day to earn our food. It is inevitable fact – most of us spend at work more than half of conscious adult life. How well do you spend this half of our life? Are you unhappy, stressed or bored on your job?

Why people are unhappy at work?

  1. Conflicts with other people and especially your boss. We all humans and, surprisingly not only you, but everybody has own agenda, interests and needs. Conflicts often happen, because we forget about this. Care about people around you and you’ll enjoy their company much more.
  2. Burnout – too much pressure, too much stress, too little time to think about yourself. Stress comes from inside – we are creators of own stress. There are hundreds ways to relieve – better organization, delegation of responsibility, better communication with co-workers. External factors are most important: enjoyment from family, home, physical activity and leisure, fulfilling personal life and achievements. At the end, we work to live, not living to work.
  3. Lack of variety and challenge. And first step to have interesting and enjoyable job is to design your job.

Designing your job

Don’t allow to treat yourself as a pluggable work unit. You should have

  1. Control over your task assignments and execution.
  2. Environment and time to focus on your tasks.
  3. Clear goals and immediate feedback.

Enjoyment from work comes at very specific point: when our tasks and challenges match our capabilities (Mihaly Csikszentmihal, Flow). Work should be not overwhelmingly complex and not too simple. With these conditions you will enjoy your work and grow quickly.

If you cannot change your job, change your job. Find another. (Strategy advise from Martin Fowler).

Me, Inc. or Hire yourself.

Don’t allow other people to decide what you do, your career and your future – not your manager, company or even trends in your profession. Take charge yourself and consider yourself as a mini enterprise.

Follow 5 step process (Pollan and Levine, Fire Your Boss).

  1. Write your own job description– One sentence with focus on active verbs.
    • Example: “I build enterprise software”.
  2. Give yourself a performance review. Look beyond your company or industry – become expert in job market. What skills and achievements are valued? What experience is required? How much people earn?
    • Example: “Companies become interested in Ruby-on-Rails, Flex, Silverlight. Agile development enters mainstream.”
  3. Define alternative paths– from 2 previous steps you’ll discover alternative courses open to you today and in a future. Brainstorm all possible fields and occupations that would fit this general description. Add imagination.
    • Example: “I can receive certification, move to another company, freelance, become consulting coach or teach programming.”
  4. Find gaps– what are you missing to move to alternative path or improve your current job position.
    • Example: “I should improve communication skills. I should learn new software platforms and try Agile.”
  5. Put your work plan in action – abandon narrow path predetermined by your boss, company or profession. Focus on achievements and skills you need to advance on your current and future job in the same time. Use a good time/goals management system as GTD. Come up with Next Actions.

Most jobs are not created to make us happy. They are created to make money for someone else. If we allow them – they will suck our lives. Instead, we should take charge, design our jobs and hire ourselves.

Sigmund Freud gave simple receipt for happiness: “Work and Love”. And I hope you can break “curse of Adam” and love your work.

Original: How to Be Happy At Work. Short tutorial

Confessions of a Successful Entrepreneur – Forbes


http://www.forbes.com/sites/rajeevpeshawaria/2012/02/21/confessions-of-a-successful-entrepreneur/

Confessions of a Successful Entrepreneur

Lessons corporate executives can learn from entrepreneurs

When my friend Jim took the giant leap from corporate executive to technology entrepreneur back in 2000, even he never imagined that he would lead a Nasdaq listed company with over 20,000 employees in eight countries by 2009. How did he pull off this rare achievement? Many things, of course – strategy, ability to execute, funding, and able leadership to name a few. I asked Jim what he believed to be the biggest reason, and without hesitation, he attributed most of his success to the fact that he made some important behavior changes along the way. As I listened to him, I realized that this (the ability to make behavior and mindset changes) is common to all successful entrepreneurs, but always missed in analyst reports. Furthermore, I strongly believe they apply equally to people who want to remain and excel in corporate executive roles.

Here are the four changes Jim made:

1. From Shut to Open

In his corporate executive avatar, the more senior he became, the more he unknowingly shut himself off from people. As he became busier, he instructed his secretary to screen his calls and sequester his time. After all, how could he entertain every caller when he could barely finish his work? His assistants also took control of his e-mail in-box, only involving him in the “most critical” ones. He ignored anyone who “wasn’t worth it”. .

Once he started his own business, he quickly realized how important networks were. “It is not what you know, but who you know that matters in business. You cannot ignore anyone these days – who knows where the next big opportunity will come from,’” he told me. With this realization, he began to return each call and email personally with curiosity. Even today, with all his responsibilities as CEO, he wakes up at 5:00 a.m. everyday, answers his email for an hour over a cup of coffee, then goes for his morning run.

2. From Opportunistic to Helpful

During his days in the corner office of the division he headed for the old company, he routinely ignored help requests from friends and acquaintances. If someone called to ask him to recommend her son for an internship position, or if a friend asked him to introduce them to his company’s procurement guys, Jim usually did not bother unless he felt the person asking was important enough and could be of use to him in future. In most cases, he thought people were taking advantage of his position at the company.

In his early days as a businessman, Jim found a lot of closed doors. He noticed that the same people who had run after him when he was a senior corporate executive were now not returning his calls. His initial anger eventually gave way to humility and he realized that he must help anyone he can without weighing the usefulness of the person. Now as CEO he often tells his senior team, “You must go out of your way to genuinely help as many people as you can even if it is unclear how they might ever be useful to you – it is just good business.”

3. From Telling to Asking

As the big shot executive, he often told everyone how important his work was. As people asked him questions, he was happy to tell them everything he knew. After all, he was an expert in his field and it was only natural that people wanted to learn as much as they could from him. He felt really good about himself as people were so in awe of him. It was quite normal for him to spend a few hours at a party and come back without knowing much about the people he had met. He usually did most of the talking.

Now one can barely get a few sentences out of him when people try to probe about the importance of his work. He is far more interested in finding out about what others do, and never stops asking questions. He even attended a memory seminar which helps him remember the names of people he meets at social gatherings. I asked him why this sea change in behavior, and he was quick with his response: “It’s all about the people – you have to be genuinely interested in them…. As I proactively built this habit, I found that I felt deep intrinsic satisfaction when I knew I had understood (and helped) someone….. And usually in turn, they do their best for you. It’s a win-win habit.”

26 questions you have to answer correctly to get funding for your startup » WhoAPI blog


http://pulse.me/s/4ewpb

26 questions you have to answer correctly to get funding for your startup

It’s been a crazy week. On Monday we announced that our project received funding. Member of the Croatian Angel Network – CRANE, Mihovil Barančić believes that we have what it takes to create something big and worth mentioning. But I am way ahead of myself. We’ve started to explore the possibility of getting an investment roughly a year ago. So here are some questions that we got during that time.

  • Why do you need an investment?
  • Why don’t you sell your house/company/whatever if you believe that much in your product?
  • Do you believe in your service?
  • What does your service do?
  • Why is that better than company x?

It’s good that your share all this info, because otherwise you’re a bozo (tm Guy Kawasaki-Steve Jobs)

  • What if some big company decides to copy your service?
  • What if your competitor or newcomer decides to copy your service and offer it half the price?
  • Is there any competition?
  • Can you see your company becoming a 10 million dollar company?
  • Why don’t you start localy first?

Why don’t you go global from the start? Since we were going global right from the start, we weren’t asked that question (but some probably will).

Interrogation

Interrogation

  • Can you bootstrap?
  • What experience do you have?
  • How did you get your idea?
  • Do you have a working prototype or a proof of concept?
  • Why should I invest in you instead of hiring 1/2/3 people and outsource the whole project?
  • Would you be willing to relocate to: capital city/London/Sillicon Valley?

If you make any kind of statement, be prepared for questions about backing up that statement with facts.

  • Do you have an executive summary?
  • Do you have a business plan?
  • How are you going to get your customers?
  • Who needs your service?
  • Who is you target audience?
  • What is your business model?
  • Do you have an exit strategy?
  • Are you prepared to give up 10%/20%/30% of equity?
  • How much money do you need?
  • Why that ammount?

I am 100% positive there were more questions, but these were the ones that first came to my mind. Good luck in finding the answers. Please, please, please help share this questions and help other startups that want to receive funding!

Author: Goran Duskic

Goran Duškić co-founded a game development team Generation Stars when he was a teenager, and he co-founded hosting and web develpoment company GEM Studio (which was sold in 2011). He co-founded tech startup WhoAPI and has 10+ experience in business development, online marketing strategy and PR.

Tags: funding questions, How to get funding, startup questions, whoapi

This entry was posted on Wednesday, December 21st, 2011 at 11:43 am and is filed under News & Updates. You can follow any comments to this entry through the RSS 2.0 feed. You can leave a comment, or trackback.

Regards,Reda Bouaichi

By Reda Bouaichi Posted in tips

What Every CEO Needs to Know About the Cloud – Harvard Business Review


http://alturl.com/miw5i

November 2011

In 2010 an IBM survey of more than 1,500 CEOs worldwide revealed a troubling gap: Close to 80% of them believed their environment would grow much more complex in the coming years, but fewer than half thought their companies were well equipped to deal with this shift. The survey team called it “the largest leadership challenge identified in eight years of research.”

Unfortunately, the information technology infrastructure at many large companies only makes this challenge more difficult. Their technology environments actually impede their ability to sense change and respond quickly. While there is no simple fix for this problem, help is at hand in the form of cloud computing, a new suite of digital tools and approaches.

Cloud computing is a sharp departure from the status quo. Today most companies own their software and hardware and keep them “on premise” in data centers and other specialized facilities. With cloud computing, in contrast, companies lease their digital assets, and their employees don’t know the location of the computers, data centers, applications, and databases that they’re using. These resources are just “in the cloud” somewhere.

To advocates of cloud computing, that’s the whole point. Customers don’t have to concern themselves with details; they just rent what they need from the cloud. (For a more detailed explanation, see the sidebar “What Is the Cloud?”)

How important is cloud computing? I would argue that it’s a sea change—a deep and permanent shift in how computing power is generated and consumed. It’s as inevitable and irreversible as the shift from steam to electric power in manufacturing, which was gaining momentum in America about a century ago. And just as that transition brought many benefits and opened up new possibilities to factory owners, so too will the cloud confer advantages on its adopters.

At present, there’s a lot of uncertainty and skepticism around the cloud, particularly among technology professionals who have deep expertise with, or attachment to, on-premise computing. Companies shouldn’t give such people too much influence over plans to move into the cloud; that would be like putting the crew that ran the boiler and steam turbine in charge of electrifying a factory. The CEO and other senior business executives need to take responsibility for bringing their organizations into the era of cloud computing.

When I talk to executives about the cloud, three questions always come up: Why will the cloud be a big deal beyond the IT department? What are the main concerns and areas of skepticism, and how valid are they? And how should we get started? In this article I’ll address those questions. I’ll explain the cloud and its benefits, highlight how perceived barriers and other concerns will keep many companies from taking full advantage of it, discuss the implications of various responses, and recommend actions.

The Benefits of the Cloud

Some people maintain that there’s nothing magic about the cloud—that anything it can do, on-premise approaches can also accomplish. That argument is correct in theory, at least for large companies that can afford comprehensive enterprise software and top IT talent. Such companies can buy or build software for collaboration or analytics—or anything else—and install it in their own data centers. They can enable these applications for different devices—desktops, laptops, tablets, and smartphones—and make them accessible to employees at home and on the road via web browsers. They can also open this infrastructure to people outside the organization, such as contractors, suppliers, and joint venture partners.

Regards,Reda Bouaichi

A Complete Resource Guide to Start a Business in 2012 | Entrepreneur.com


http://www.entrepreneur.com/article/222490?utm_source=twitterfeed&utm_medium=twitter&utm_campaign=Feed%3A+entrepreneur%2Flatest+%28Entrepreneur%29

A Complete Resource Guide to Start a Business in 2012

New Year Resources

If you’re planning to launch a business in 2012, you’ll need every last penny you can get your hands on. That’s why we put together a guide to free and low-cost resources to help you ease smoothly into the world of entrepreneurship.

It’s still tough out there. Credit remains relatively tight, and consumers are cautious. So arm yourself with valuable information that will help you to get off to a winning start. We’re here to help. Here are the essential steps you’ll need to take to get your new business off the ground.

Figure out the right concept. To be successful and happy in your own business, you need to think seriously about how you like to spend your time and where you want to live. After you’ve come up with a business concept that suits you personally, the next step is to research the competition, your prospective customers and the cost of getting started.

Related: Five Affordable Consumer Research Tools

Create a business plan. Putting your goals on paper will help you focus your concept. A business plan typically includes details about the product or service, the competition and target consumers, plus a cash-flow projection. You’ll also want to come up with a clever name for your startup.

  • Explore our how-to guides on business plans, including the basics of writing your plan, what you must include and where to find help.
  • As you consider names for your business, be sure to check the U.S. Patent and Trademark Office’s website to make sure they aren’t already taken.
  • You’ll need to determine the structure of your business for tax purposes. Study the SBA’s list of possibilities and tax implications for each one.
  • Find your local chapter of SCORE, a nonprofit association created to educate and mentor entrepreneurs. It may be able to refer you to local business owners to serve as advisers.
  • If you plan to recruit employees, look for guidance in our hiring center, including how to start employees on the right track. You can also review the SBA’s 10 steps to making your first hire.

Find Financing. The idea is hatched, the plan is set. But nothing happens without some green. Getting a loan could prove challenging because banks often are hesitant to lend to someone without a track record. And another traditional credit source—the home equity loan—has become harder to come by since the housing market cratered and home values plummeted. So it just might be time to hit up friends and family and draw on your personal savings.

Related: What Technologies Banks Should Be Using to Keep Your Money Safe

Develop and execute a marketing plan. In the Internet age, you can choose from an ever-expanding array of marketing tools, including traditional media, social networks, blogs, email and pay-per-click ads. They all require time and money, and the trick is to determine which offer the best return on investment for your particular business.

Related: Seven Tips for Improving Pay-Per-Click Campaigns

Start selling. When you hang out the “open” sign, be ready to meet your new customers with enthusiasm and the right sales pitch. Once you start attracting customers, you’ll need to figure out how to keep them coming back with great service, new products and promotions.

Related: Two Weeks to Startup

Did you find this story helpful? YesNo

Regards,Reda Bouaichi

Why I Quit My Job to Build eval.me | Blog | eval.me | Form Builder | Online Form | Email Survey


http://pulse.me/s/3QLmt

WHY I QUIT MY JOB TO BUILD EVAL.ME

Posted on December 5, 2011

Hi. I’m Flaviu. 4 months ago, I had a cushy IT job with the State. Today, I launched eval.me.

The Why:

1. What doesn’t make you stronger, kills you.

or, to rephrase another adage, “Learning is more important than knowledge.”

I feel most alive when learning something new. In any field.

Most jobs hire you for being relatively good at something. They want you to keep doing that one thing to increase their efficiency.

While this increases their efficiency in the short run, it hurts them in the long term as you start viewing your job as ‘soul-sucking’.

The lack of a challenge kills one’s potential. On the other hand, having a startup will always be a challenge.

2. It’s the only choice.

You’re thinking about starting a business. You may think you have three choices:

1. Stay with your job (your idea isn’t that good anyway).

2. Stay with your job and work on your idea at nights and weekends.

3. Leave your job and ‘sink or swim’.

1. is not an option because it sets you up for living with regrets. You’ll always wonder what could have happened if you had pursued your idea.

2. seems to be an option because you always hear about ventures starting out as side-projects built on late nights and weekends.

Well, I only have a few hours of focus every day. By midnight, I just blankly stare at my screen. Maybe it works for you, but it took me 2 years to figure out it does not work for me.

3. is the only real option. Even if you just somewhat believe in your idea, you owe it to yourself (and potential clients) to implement it. Even if it fails, you’ll have no regrets.

3. It’s your social responsibility.

Startups add some value to the world, whether that is making a process more efficient, inventing a new way to connect with others, or simply entertaining the masses with virtual goods.

The very fact that you are in a position to create a startup is the result of a series of fortunate events: you are smart, healthy, creative, self-sustaining, and courageous. To not do a startup would be a waste of these talents.

The world’s advancement relies on people like you realizing their potential.

Note:

I would not have subscribed to the belief above 2 years ago.

I’ve since participated in a few charity projects with my Rotary club, including an effort to equip the middle school I attended in Nasaud, Romania with a computer lab of Apple iMacs this past summer. Here are some pictures.

The meaning of such projects is much greater than anything I’ve accomplished professionally. Hence, combining startups and social good in eval.me motivates me most.

The How:

1. Save.

I was able to save just over $10,000 to help me bootstrap eval.me. I firmly believe that my first startup needed to be on my own dime to feel every mistake.

I cut monthly expenses by about 50% by getting a roommate, cooking more, and not watching TV.

2. Code.

It’s trendy to advise business people to learn how to code before doing a startup. I already knew how to code, but there are many other technical challenges besides coding.

For instance, I needed a 1 minute video to present my startup. I could have learned Adobe After Effects, and try to do it myself, but I decided that my time would be better spent elsewhere. So, I paid $1,000 for the animation and voice-over (mind you, I still wrote the script and spent hours coordinating the story board).

Maybe a more realistic advice would be to “Learn a little bit of coding, design, SEO, project management, read hackernews, and listen to some podcasts.”

It is worth noting that while I did most of the coding, I also had some great help from a few very talented machers (I’m looking at you, @fansipans, @floomoon, @lukedupont, and @fldtrace)

3. There’s more than 24 hours in a day.

Developers are often frustrated when asked how long it will take them to build a certain feature.

My original deadline for eval.me was October 15th, which became November 1st, which became November 18th, then November 28th, and today is December 5th.

If you had ordered something from Amazon and it came 2 months late, it would be inexcusable. But the iterative process of innovation is unlike any corporate assembly line. Make sure your coworkers understand that a task may take anywhere between 10 minutes and 3 days.

4. Focus.

Don’t count your startup hours like your freelance hours. You can’t charge yourself $100/hr and it will only frustrate you to know your opportunity cost.

Finishing the MVP is Priority #1. At all times. Anything else is a distraction: hackernews, twitter, food, sleep, gmail, friends. Saying no is hard for me because I enjoy talking to the smart people that surround me in the Charlotte community.

However, to fail is to succeed. Leaving something unfinished, that’s failure.

Using JAXB to generate XML from the Java, XSD


Reference

We can use JAXB to marshal the Java objects into XML using the given Schema and vice versa- unmarshal XML into Java objects. The xml schema can be specified in DTD, XSD or other format. The tool “xjc” is used to generate the annotated Java classes from the XSD schema. One can download the Java WSDP from here, it includes the JAXB implementation tools required. Here I will throw light on how to generate XML dynamically. Even I havent gone in depth with JAXB, but I found this really useful and thought of sharing it in the blog.

The sample XSD being used is: expense.xsd

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?xml version="1.0"?></div>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="expenseReport" type="ExpenseT" />
<xs:complexType name="ExpenseT">
    <xs:sequence>
        <xs:element name="user" type="UserT"/>
        <xs:element name="items" type="ItemListT"/>
    </xs:sequence>
</xs:complexType>
<xs:complexType name="UserT">
    <xs:sequence>
        <xs:element name="userName" type="xs:string" />
    </xs:sequence>
</xs:complexType>
<xs:complexType name="ItemListT">
     <xs:sequence>
         <xs:element name="item" type="ItemT" maxOccurs="unbounded"/>
     </xs:sequence>
</xs:complexType>
<xs:complexType name="ItemT">
     <xs:sequence>
         <xs:element name="itemName" type="xs:string" />
         <xs:element name="purchasedOn" type="xs:string" />
         <xs:element name="amount" type="xs:decimal" />
     </xs:sequence>
</xs:complexType>
</xs:schema>

You can read about XSD here.

Now we use the xjc tool to generate corresponding Java classes. The generate java classes are annotated appropriately. Am not going into the annotation of the classes, cause it would make things complicated.

1
xjc.exe expense.xsd

By default the command generates the Java classes in a directory named “generated”. There are lot of options which can be used with xjc and one can have a look at using- xjc -help.

The below Main class- Main.java uses the generated classes for creating the XML.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package generated;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.math.BigDecimal;
public class Main
{
    public static void main(String[] args) throws JAXBException
    {
        ObjectFactory factory = new ObjectFactory();
        UserT user = factory.createUserT();
        user.setUserName("Sanaulla");
        ItemT item = factory.createItemT();
        item.setItemName("Seagate External HDD");
        item.setPurchasedOn("August 24, 2010");
        item.setAmount(new BigDecimal("6776.5"));
        ItemListT itemList = factory.createItemListT();
        itemList.getItem().add(item);
        ExpenseT expense = factory.createExpenseT();
        expense.setUser(user);
        expense.setItems(itemList);
        JAXBContext context = JAXBContext.newInstance("generated");
        JAXBElement<ExpenseT> element = factory.createExpenseReport(expense);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty("jaxb.formatted.output",Boolean.TRUE);
        marshaller.marshal(element,System.out);
    }
}

In the above XSD, we see that there are few complex types declared. These complex types generate in to Java classes. The child elements and attributes become the properties of the class and they are provided with the getters and setters. One cannot directly create the instance of such classes i.e cannot call new on them. When ever we compile a XSD, there is a ObjectFacotry class generated- this is the factory for creating the instances of the XSD Complex types (Lines-17,19, 24, 27 in the above Java class). Once we get the instance we populate the properties with corresponding data using the setters provided with the class. Also note that- A complex element can have many complex elements as the members of the class. In that case what happens we use the factory to get the instance of the complex elements and then use the setters of the outer complex element. For example: In the above XSD- ExpenseT is a complex type which consists of UserT and a list of ItemT (ItemListT). In the above Java class- Lines-27,28,29- am creating an instance of ExpenseT and then using the setters to set the values of the UserT and ItemListT. The RootElement- is created by calling createExpenseReport() for the factory. The name of the method is influenced by the name of the root element and the return type and the argument type of the method is same as that of the type of root element.

Once we have set the values for the different elements, attributes which are to go into the XML, its now time to actually generate the XML. We must have an Marshaller (To get XML from the Java objects) or an Unmarshaller (to get java objects from XML). We would need a Marshaller- which can be obtained from the JAXBContext instance. Lines- 31,32 obtain an instance of Marshaller. Different properties can be set for the marshaller and in the above code we are setting the jaxb.formatted.output as true- which means that the xml obtained is neatly formatted making is readable to the user.

Different properties supported are:

  • jaxb.encoding
  • jaxb.formatted.output
  • jaxb.schemaLocation
  • jaxb.noNamespaceSchemaLocation
  • jaxb.fragment

<instance_of_marshaller>.marshal() is the method used to generate the XML. Its is overloaded to accept the following output mechanisms:

  • org.xml.sax.ContentHandler
  • org.w3c.dom.Node
  • javax.xml.transform.Result
  • java.io.Writer
  • java.io.OutputStream
  • javax.xml.stream.XMLStreamWriter
  • javax.xml.stream.XMLEventWriter

The xml generated is shown below:

01
02
03
04
05
06
07
08
09
10
11
12
13
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <expenseReport>
    <user>
      <userName>Sanaulla</userName>
   </user>
   <items>
     <item>
       <itemName>Seagate External HDD</itemName>
       <purchasedOn>August 24, 2010</purchasedOn>
       <amount>6776.5</amount>
     </item>
   </items>
</expenseReport>

PS: I havent gone much into the details of JAXB. This is just the overview of how one can generate XML confirming to the schema.

JavaScript Regular expressions


Regular Expressions for client-side JavaScript

a free online quick reference by VisiBone
Regular Expressions (column 1 from a page of the JavaScript Card)
I hope you find these
excerpts of the VisiBone
JavaScript references
very useful.

See also the
JavaScript Card 
and Foldouts

Here is the syntax
for a very powerful
and very cryptic
string pattern
matching scheme
in the client-side
JavaScript of
web browsers.

You can use it to
validate form entry,
parse URLs, and
many other things.

The information here
forms a page of the 
JavaScript Card:
 JavaScript Card

and is one of the set
of three JavaScript 
Foldouts:
 JavaScript Regular Expressions Foldout (page 1)
 JavaScript Regular Expressions Foldout (pages 2-5)
 JavaScript Regular Expressions Foldout (pages 6-8)

Regular Expressions (column 2 from a page of the JavaScript Card)


Regular Expressions (column 3 from a page of the JavaScript Card)
Regular Expressions (column 4 from a page of the JavaScript Card)

VisiBone also makes
several printed web
color references.

Posters & Charts
Webmaster's Palette Color Wheel Poster

Laminated Cards
Color Card, laminated and slick for clients
that match the 
“VisiBone2”
swatch collection 
in Adobe
Illustrator and 
Photoshop.

Plus two varieties 
of Mouse Pads.

And a chart with 
1068
non-web-safe
colors:
Web Color KiloChart

Feedback welcome!