Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(URGENT) Support parsing of CDATA #116

Open
andrew2net opened this issue Oct 24, 2024 · 2 comments
Open

(URGENT) Support parsing of CDATA #116

andrew2net opened this issue Oct 24, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@andrew2net
Copy link

The title and normtitle are not parsed:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE publication PUBLIC "-//IEEE//IDAMS Exchange V2.0.0//EN" "ieee_idams_exchange.dtd">
<publication>
  <title><![CDATA[IEEE Std 1430-1996]]></title>
  <normtitle><![CDATA[IEEE Std 1430-1996]]></normtitle>
  <standardsfamilytitle>IEEE Guide for Information Technology Software Reuse-Concept of Operations for Interoperating Reuse Libraries [Developed in cooperation with the Reuse Library Interoperability Group (RIG)]</standardsfamilytitle>
  ...

The lutaml-model is:

module Ieee
  module Idams
    # Represents an IEEE IDAMS publication record
    class Publication < Lutaml::Model::Serializable
      # Publication title
      # @return [String] normalized title
      attribute :title, :string

      # Publication normalized title
      # @return [String] normalized title
      attribute :normtitle, :string

      # Standards family title
      # @return [String] family title for standards
      attribute :standardsfamilytitle, :string

      # Publication information
      # @return [PublicationInfo] detailed publication metadata
      attribute :publicationinfo, PublicationInfo

      # Volume information
      # @return [Volume] volume details
      attribute :volume, Volume

      xml do
        root "publication"
        map_element "title", to: :title
        map_element "normtitle", to: :normtitle
        map_element "standardsfamilytitle", to: :standardsfamilytitle
        map_element "publicationinfo", to: :publicationinfo
        map_element "volume", to: :volume
      end
    end
  end
end

Does lutaml-model have ability to parse CDATA?

@HassanAkbar
Copy link
Member

@andrew2net We currently do not support cdata in Lutaml::Model, I will create a ticket and add support for this ASAP.

@ronaldtse ronaldtse changed the title URGENT! How to parse CDATA? (URGENT) Support parsing of CDATA Oct 25, 2024
@ronaldtse
Copy link
Contributor

ronaldtse commented Oct 25, 2024

@HassanAkbar I've renamed this issue, let's just use this issue for CDATA support.

  1. CDATA should always be read because it is just a string (string type). CDATA only works for XML elements, not attributes.

  2. In the XML block, we need to specify whether the text should be encoded as "CDATA" or text. e.g.

attribute :title, :string

xml do
  map_element :title, to: :title, cdata: true     # read cdata or string, produce only cdata
  map_element :title, to: :title, cdata: false    # read cdata or string, produce only string
end

Also need to update README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants