DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Data Governance Essentials: Glossaries, Catalogs, and Lineage (Part 5)
  • How to Simplify Complex Conditions With Python's Match Statement
  • Modify JSON Data in Postgres and Hibernate 6
  • Practical Generators in Go 1.23 for Database Pagination

Trending

  • The 4 R’s of Pipeline Reliability: Designing Data Systems That Last
  • Java Virtual Threads and Scaling
  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  • AI, ML, and Data Science: Shaping the Future of Automation
  1. DZone
  2. Data Engineering
  3. Data
  4. The X-Factor: RAML With XML Format

The X-Factor: RAML With XML Format

Want to know more about the X-Factor? Read this article to understand how RAML can be defined for resource representation in XML format.

By 
Ruchi Saini user avatar
Ruchi Saini
DZone Core CORE ·
Feb. 18, 22 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
16.5K Views

Join the DZone community and get the full member experience.

Join For Free

I want X-Factor

In this article, we will explore how RAML specifications can be defined for the XML representation of resources. This will be explained with the help of JOB API. Consider this API for the purpose of getting a list of all jobs published by different companies. A job can also be posted using this JOB API.

JOB API

  • Resource: Jobs
  • Resource Path: /jobs
  • Methods:
    • GET: To retrieve a list of all jobs
    • POST:  To add a job

JSON Representation

This is how everyone talks in JSON

Let's start with JSON.  RAML Specification with media type as application/JSON is shown below:

RAML Specification with media type as application/JSON

Data type fragment of job data type:

Data type fragment of job data type

Test GET method of/jobs using Mocking Service. The response is:

Test GET method of/jobs using Mocking Service response

But now we want the representation of the job resource in XML format also.

XML Representation

Let's specify the media type as application/XML:

Specify the media type as application/XML

Test the GET method using the Mocking service. Specify the accept header value as application/XML. The response will be:

Test the GET method using the Mocking service response

Simple!! Right?

Changing Root Tag

I don't like my birth markNow we don't want our root tag to be model. So let's change it to jobs. Specify the name using XML node as shown below:

Specify the name using XML node

Test using Mocking Service again with Accept Header value as application/XML. The response is:

Test using Mocking Service again with Accept Header value as application/XML

Location Data Type

Now we want to specify the Location where this job is applicable.

I want to go places with you

So let's create a Location Data Type. Location Data Type fragment is:

Location Data Type fragment

Job Data Type is updated with Location property and it is defined using Location data type fragment:

Job Data Type is updated with Location property

Example fragments are also updated. One of the example fragments is shown below:

One of the example fragments

Test using Mocking Service again. The response is:

Test using Mocking Service response

Now, let's change the name of the location tag to JobLocation :

change the name of the location tag to JobLocation

Let's test using Mocking Service again. Now the response is:

Mocking Service response

Attributes

He is just my typeLet's make JobTitle the attribute of the job tag. So change the job data type as follows:

Change the job data typeNo change in examples. Test using Mocking Service. The response is:

Mocking Service response updated

POST Method

I am hereIn case you are wondering what the POST request looks like in our scenario, take a look:

 POST request

I have X-Factor now

JSON

JSON can you follow me?

Let's check what the GET Response looks like with JSON Representation after all these changes. Test using Mocking Service with Accept header value as application/JSON. The response is:

GET Response with JSON Representation

We have defined RAML to have resource representation in both XML and JSON.

Happy X-Factoring!

XML Data Types career Data (computing)

Opinions expressed by DZone contributors are their own.

Related

  • Data Governance Essentials: Glossaries, Catalogs, and Lineage (Part 5)
  • How to Simplify Complex Conditions With Python's Match Statement
  • Modify JSON Data in Postgres and Hibernate 6
  • Practical Generators in Go 1.23 for Database Pagination

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!