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

schemaLocation is not really supported #3

Open
ronaldtse opened this issue May 22, 2024 · 1 comment
Open

schemaLocation is not really supported #3

ronaldtse opened this issue May 22, 2024 · 1 comment

Comments

@ronaldtse
Copy link

In XML files there are many occasions that alongside an XML namespace declaration, a schemaLocation is also provided.

e.g.

         -<?xml version="1.0" encoding="UTF-8"?>
         -<gml:Dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml/3.2" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/profiles/SimpleDictionary/1.0.0/gmlSimpleDictionaryProfile.xsd" gml:id="cl_e3c8f730-a2a0-4883-bf3c-1c8dcefdf693">
         +<?xml version="1.0" encoding="utf-8"?>
         +<gml:Dictionary xmlns:gml="http://www.opengis.net/gml/3.2" gml:id="cl_e3c8f730-a2a0-4883-bf3c-1c8dcefdf693">

Notice that in the original <gml:Dictionary> it contains schemaLocation. However, in Shale I have to manually encode schemaLocation as a data attribute, which is quite crazy.

@ronaldtse
Copy link
Author

The workaround is actually this:

class SomeClass < Shale::Mapper
  attribute :schema_location, Shale::Type::String

  xml do
    root "Dictionary"

    map_attribute "schemaLocation", to: :schema_location, prefix: "xsi", namespace: "http://www.w3.org/2001/XMLSchema-instance"
end

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

No branches or pull requests

1 participant