Author: adelmelle
Date: Sun Feb 3 04:05:49 2008
New Revision: 617976
URL: http://svn.apache.org/viewvc?rev=617976&view=rev
Log:
Added very basic parsing for the xml:lang shorthand.
No validation of the specified value, but the language and country
properties now do take the shorthand into account to determine their
value.
Added:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
(with props)
xmlgraphics/fop/trunk/test/fotree/testcases/xml-lang_shorthand-expansion.fo
(with props)
Modified:
xmlgraphics/fop/trunk/src/documentation/content/xdocs/compliance.ihtml
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/PropertyList.java
xmlgraphics/fop/trunk/status.xml
Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/compliance.ihtml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/documentation/content/xdocs/compliance.ihtml?rev=617976&r1=617975&r2=617976&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/compliance.ihtml
(original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/compliance.ihtml Sun
Feb 3 04:05:49 2008
@@ -1223,7 +1223,7 @@
yes </td>
<td class="yes">
yes </td>
- <td align="center"> </td>
+ <td align="center"> </td>
</tr>
<tr>
<td>
@@ -5612,9 +5612,9 @@
<td class="no"> no </td>
<td class="no">
no </td>
- <td class="no">
- no </td>
- <td align="center"> </td>
+ <td class="yes">
+ yes </td>
+ <td align="center">[dev] Very basic parsing; no validation of the
specified value.</td>
</tr>
</table>
<h1><a name="fo-function-core-library-section">XSL-FO Core Function Library
Support Table</a> (<a
href="http://www.w3.org/TR/2001/REC-xsl-20011015/slice5.html#section-N8434-Core-Function-Library">§5.10</a>)</h1>
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java?rev=617976&r1=617975&r2=617976&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java Sun
Feb 3 04:05:49 2008
@@ -66,6 +66,7 @@
import org.apache.fop.fo.properties.ToBeImplementedProperty;
import org.apache.fop.fo.properties.VerticalAlignShorthandParser;
import org.apache.fop.fo.properties.WhiteSpaceShorthandParser;
+import org.apache.fop.fo.properties.XMLLangShorthandParser;
/**
* This class creates and returns an array of Property.Maker instances
@@ -1060,12 +1061,14 @@
m = new StringProperty.Maker(PR_COUNTRY);
m.setInherited(true);
m.setDefault("none");
+ m.addShorthand(s_generics[PR_XML_LANG]);
addPropertyMaker("country", m);
// language
m = new StringProperty.Maker(PR_LANGUAGE);
m.setInherited(true);
m.setDefault("none");
+ m.addShorthand(s_generics[PR_XML_LANG]);
addPropertyMaker("language", m);
// script
@@ -2722,9 +2725,10 @@
addPropertyMaker("white-space", m);
// xml:lang
- m = new ToBeImplementedProperty.Maker(PR_XML_LANG);
+ m = new StringProperty.Maker(PR_XML_LANG);
m.setInherited(true);
m.setDefault("");
+ m.setDatatypeParser(new XMLLangShorthandParser());
addPropertyMaker("xml:lang", m);
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/PropertyList.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/PropertyList.java?rev=617976&r1=617975&r2=617976&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/PropertyList.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/PropertyList.java Sun Feb
3 04:05:49 2008
@@ -310,11 +310,13 @@
String attributeNS;
FopFactory factory = getFObj().getUserAgent().getFactory();
for (int i = 0; i < attributes.getLength(); i++) {
- /* convert all attributes with the same namespace as the fo
element for this fObj */
+ /* convert all attributes with the same namespace as the fo element
+ * the "xml:lang" property is a special case */
attributeNS = attributes.getURI(i);
attributeName = attributes.getQName(i);
attributeValue = attributes.getValue(i);
- if (attributeNS == null || attributeNS.length() == 0) {
+ if (attributeNS == null || attributeNS.length() == 0
+ || "xml:lang".equals(attributeName)) {
convertAttributeToProperty(attributes, attributeName,
attributeValue);
} else if (!factory.isNamespaceIgnored(attributeNS)) {
ElementMapping mapping =
factory.getElementMappingRegistry().getElementMapping(
Added:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java?rev=617976&view=auto
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
(added)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
Sun Feb 3 04:05:49 2008
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+/* $Id:$ */
+
+package org.apache.fop.fo.properties;
+
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+
+public class XMLLangShorthandParser extends GenericShorthandParser {
+
+ private static final char HYPHEN_MINUS = '-';
+
+ /** [EMAIL PROTECTED] */
+ public Property getValueForProperty(int propId,
+ Property property,
+ PropertyMaker maker,
+ PropertyList propertyList)
+ throws PropertyException {
+
+ String shorthandValue = property.getString();
+ int hyphenIndex = shorthandValue.indexOf(HYPHEN_MINUS);
+ if (propId == Constants.PR_LANGUAGE) {
+ if (hyphenIndex == -1) {
+ /* only language specified; use the whole property */
+ return property;
+ } else {
+ /* use only the primary tag */
+ return StringProperty.getInstance(
+ shorthandValue.substring(0, hyphenIndex));
+ }
+ } else if (propId == Constants.PR_COUNTRY) {
+ if (hyphenIndex != -1) {
+ int nextHyphenIndex = shorthandValue.indexOf(HYPHEN_MINUS,
hyphenIndex + 1);
+ if (nextHyphenIndex != -1) {
+ return StringProperty.getInstance(
+ shorthandValue.substring(hyphenIndex + 1,
nextHyphenIndex));
+ } else {
+ return StringProperty.getInstance(
+ shorthandValue.substring(hyphenIndex + 1));
+ }
+ }
+ }
+ return null;
+ }
+}
Propchange:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/XMLLangShorthandParser.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/trunk/status.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=617976&r1=617975&r2=617976&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Sun Feb 3 04:05:49 2008
@@ -28,6 +28,9 @@
<changes>
<release version="FOP Trunk">
+ <action context="Code" dev="AD" type="add">
+ Added very basic parsing for the xml:lang shorthand.
+ </action>
<action context="Code" dev="AD" type="fix" fixes-bug="44343">
Fixed a bug when using relative font-size (smaller/larger) in
combination
with percentages.
Added:
xmlgraphics/fop/trunk/test/fotree/testcases/xml-lang_shorthand-expansion.fo
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/fotree/testcases/xml-lang_shorthand-expansion.fo?rev=617976&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/fotree/testcases/xml-lang_shorthand-expansion.fo
(added)
+++ xmlgraphics/fop/trunk/test/fotree/testcases/xml-lang_shorthand-expansion.fo
Sun Feb 3 04:05:49 2008
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- $Id$ -->
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:test="http://xmlgraphics.apache.org/fop/test">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="normal" page-width="5in"
page-height="5in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="normal" xml:lang="en-US">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block white-space="normal">
+ <test:assert property="language" expected="en" />
+ <test:assert property="country" expected="US" />
+ Block 1
+ </fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+
Propchange:
xmlgraphics/fop/trunk/test/fotree/testcases/xml-lang_shorthand-expansion.fo
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
xmlgraphics/fop/trunk/test/fotree/testcases/xml-lang_shorthand-expansion.fo
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]