Skip to content

Commit

Permalink
3: Add height and width attributes to image and credit-image elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Good committed Jul 20, 2016
1 parent c0804d0 commit 521c223
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 2 deletions.
9 changes: 8 additions & 1 deletion schema/direction.mod
Expand Up @@ -320,12 +320,19 @@
for the image file. The required type attribute is the
MIME type for the image file format. Typical choices
include application/postscript, image/gif, image/jpeg,
image/png, and image/tiff.
image/png, and image/tiff. The optional height and width
attributes are used to size and scale an image. The image
should be scaled independently in X and Y if both height
and width are specified. If only one attribute is specified,
the image should be scaled proportionally to fit in the
specified dimension.
-->
<!ELEMENT image EMPTY>
<!ATTLIST image
source CDATA #REQUIRED
type CDATA #REQUIRED
height %tenths; #IMPLIED
width %tenths; #IMPLIED
%position;
%halign;
%valign-image;
Expand Down
4 changes: 3 additions & 1 deletion schema/musicxml.xsd
Expand Up @@ -1887,10 +1887,12 @@ For mordent and inverted-mordent elements, the defaults are different:

<xs:attributeGroup name="image-attributes">
<xs:annotation>
<xs:documentation>The image-attributes group is used to include graphical images in a score. The required source attribute is the URL for the image file. The required type attribute is the MIME type for the image file format. Typical choices include application/postscript, image/gif, image/jpeg, image/png, and image/tiff.</xs:documentation>
<xs:documentation>The image-attributes group is used to include graphical images in a score. The required source attribute is the URL for the image file. The required type attribute is the MIME type for the image file format. Typical choices include application/postscript, image/gif, image/jpeg, image/png, and image/tiff. The optional height and width attributes are used to size and scale an image. The image should be scaled independently in X and Y if both height and width are specified. If only one attribute is specified, the image should be scaled proportionally to fit in the specified dimension.</xs:documentation>
</xs:annotation>
<xs:attribute name="source" type="xs:anyURI" use="required"/>
<xs:attribute name="type" type="xs:token" use="required"/>
<xs:attribute name="height" type="tenths"/>
<xs:attribute name="width" type="tenths"/>
<xs:attributeGroup ref="position"/>
<xs:attributeGroup ref="halign"/>
<xs:attributeGroup ref="valign-image"/>
Expand Down
2 changes: 2 additions & 0 deletions schema/score.mod
Expand Up @@ -115,6 +115,8 @@
<!ATTLIST credit-image
source CDATA #REQUIRED
type CDATA #REQUIRED
height %tenths; #IMPLIED
width %tenths; #IMPLIED
%position;
%halign;
%valign-image;
Expand Down
99 changes: 99 additions & 0 deletions schema/to30.xsl
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
MusicXML to30.xsl stylesheet
Version 3.1 Draft
Copyright © 2004-2016 the Contributors to the MusicXML
Specification, published by the W3C Music Notation Community
Group under the W3C Community Contributor License Agreement
(CLA):
https://www.w3.org/community/about/agreements/cla/
A human-readable summary is available:
https://www.w3.org/community/about/agreements/cla-deed/
-->

<!--
To30.xsl converts from MusicXML 3.1 to 3.0 for
compatibility with older products.
-->

<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!--
XML output, with a DOCTYPE refering the partwise DTD.
Here we use the full Internet URL.
-->

<xsl:output method="xml" indent="yes" encoding="UTF-8"
omit-xml-declaration="no" standalone="no"
doctype-system="http://www.musicxml.org/dtds/partwise.dtd"
doctype-public="-//Recordare//DTD MusicXML 3.0 Partwise//EN" />

<!--
For the root, only look for score-partwise. Anything else
as a root element gets ignored.
-->
<xsl:template match="/">
<xsl:apply-templates select="./score-partwise"/>
</xsl:template>

<!--
Transformations that remove post-3.0 elements and
attributes.
-->

<!-- Additions in note.mod -->

<!-- Additions in attributes.mod -->

<!-- Additions in barline.mod -->

<!-- Additions in common.mod -->

<!-- Additions in direction.mod -->

<xsl:template
match="image/@height | image/@width"/>

<!-- Additions in layout.mod -->

<!-- Additions in score.mod -->

<xsl:template
match="credit-image/@height | credit-image/@width"/>

<!--
Convert score version attribute to 3.0
-->
<xsl:template
match="score-partwise/@version | score-timewise/@version">
<xsl:attribute name="version">3.0</xsl:attribute>
</xsl:template>

<!--
The identity transformation. Used for everything that
stays the same in 3.0.
-->

<xsl:template match="text()">
<xsl:value-of select="." />
</xsl:template>

<!--
Whitespace within an xsl:copy could cause problems with
empty elements.
-->
<xsl:template match="*|@*|comment()|processing-instruction()">
<xsl:copy><xsl:apply-templates
select="*|@*|comment()|processing-instruction()|text()"
/></xsl:copy>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 521c223

Please sign in to comment.