You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sl...@apache.org on 2018/12/11 13:31:44 UTC

[incubator-daffodil] branch master updated: Support dfdl:length="prefixed"

This is an automated email from the ASF dual-hosted git repository.

slawrence pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git


The following commit(s) were added to refs/heads/master by this push:
     new 2f2e9b5  Support dfdl:length="prefixed"
2f2e9b5 is described below

commit 2f2e9b599a01424134c99d0928b81d8eb8eb5d09
Author: Steve Lawrence <sl...@apache.org>
AuthorDate: Mon Oct 8 13:45:46 2018 -0400

    Support dfdl:length="prefixed"
    
    - Add a concept of a "detached element". This is an element that has no
      representation in the infoset, acting only as a place to hang
      properties and as a temporary infoset element to parse unparse.
    - When parsing a prefix element, this creates a new detached element,
      parses the prefix length into the element, pulls out the length from
      the element, then uses that length for parsing the actual data. The
      reverse process is performed on unparse, except in the case of binary
      number where the lengths are predetermined by the specification.
    - Rename OVCRetry to SimpleTypeRetry, since this is now used to retry
      the prefix length unparser, which has the same behavior as output
      value calc. It will suspend until something figures out the prefix
      length, sets the simple value, and then it can resume and unparse that
      value.
    - Add many new binary related parsers/unparsers to handle prefix
      lengths. Text representations are all handled the same using specified
      length parsers/unparsers. This involved some level of refactoring to
      keep things somewhat clean, but not what is really needed. The binary
      parsers all have subtle differences which make this challenging.
    - Modified the property generator to resolve QNames.
    - For packed numbers, split out the length determination from the
      function that converts to a byte array. With prefixed lengths, we need
      to know how much minimum space is needed without needing to create the
      entire array.
    - This does not support the ability to nest prefix lengths.
      Functionally, work is complete for parsing, but the uparsing side
      requires modifications to how UState is cloned. Nesting prefix lengths
      results in nesting suspensions, which doesn't work right now--one
      cannot create suspension from inside a suspension.
    - This does not support the ability to unparse prefix lengths when
      lengthUnits is characters. This is a similar issue to trying to use
      content/value-length functions with 'characters'.
    - Consolidate content/value length capture logic into single functions
    
    DAFFODIL-114
---
 .../org/apache/daffodil/dsom/ElementBase.scala     |   99 +-
 .../apache/daffodil/dsom/LocalElementDecl.scala    |   19 +-
 .../daffodil/dsom/RuntimePropertyMixins.scala      |    3 +-
 .../main/scala/org/apache/daffodil/dsom/Term.scala |    6 +-
 .../org/apache/daffodil/grammar/AlignedMixin.scala |    5 +-
 .../daffodil/grammar/ElementBaseGrammarMixin.scala |  197 +-
 .../grammar/primitives/ElementCombinator.scala     |   83 +-
 .../grammar/primitives/PrimitivesBCD.scala         |   59 +-
 .../primitives/PrimitivesBinaryBoolean.scala       |   22 +
 .../primitives/PrimitivesBinaryNumber.scala        |   81 +-
 .../primitives/PrimitivesIBM4690Packed.scala       |   56 +-
 .../grammar/primitives/PrimitivesLengthKind.scala  |   50 +-
 .../grammar/primitives/PrimitivesPacked.scala      |   65 +-
 .../grammar/primitives/SpecifiedLength.scala       |   39 +
 .../schema/annotation/props/Properties.scala       |    5 +-
 .../org/apache/daffodil/util/DecimalUtils.scala    |   62 +-
 .../daffodil/propGen/PropertyGenerator.scala       |   13 +-
 .../daffodil/propGen/TestPropertyGenerator.scala   |    3 +-
 .../processors/unparsers/BCDUnparsers.scala        |   70 +-
 .../unparsers/BinaryBooleanUnparsers.scala         |  105 +-
 .../unparsers/BinaryNumberUnparsers.scala          |  106 +-
 .../unparsers/HexBinaryLengthUnparser.scala        |   38 +-
 .../unparsers/IBM4690PackedDecimalUnparsers.scala  |   74 +-
 .../processors/unparsers/NilUnparsers.scala        |    4 +-
 .../unparsers/PackedBinaryUnparserTraits.scala     |   60 +-
 .../unparsers/PackedDecimalUnparsers.scala         |   71 +-
 .../processors/unparsers/SpecifiedLength2.scala    |   38 +-
 .../unparsers/SpecifiedLengthUnparsers.scala       |  168 +-
 .../apache/daffodil/processors/BCDParsers.scala    |   54 +-
 .../org/apache/daffodil/processors/EvElement.scala |   24 +-
 .../processors/IBM4690PackedDecimalParsers.scala   |   56 +-
 .../daffodil/processors/PackedDecimalParsers.scala |   58 +-
 .../processors/parsers/BinaryBooleanParsers.scala  |   84 +-
 .../processors/parsers/BinaryNumberParsers.scala   |   49 +-
 .../processors/parsers/BinaryNumberTraits.scala    |   78 +-
 .../parsers/HexBinaryLengthParsers.scala           |   22 +
 .../parsers/SpecifiedLengthParsers.scala           |   55 +-
 .../section12/lengthKind/PrefixedTests.tdml        | 1995 ++++++++++++++++++++
 .../lengthKind/TestLengthKindPrefixed.scala        |  142 ++
 39 files changed, 3848 insertions(+), 370 deletions(-)

diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ElementBase.scala b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ElementBase.scala
index e2687e1..812d2bc 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ElementBase.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/ElementBase.scala
@@ -170,58 +170,93 @@ trait ElementBase
    *  Tells us if, for this element, we need to capture its content length
    *  at parse runtime, or we can ignore that.
    */
-  final lazy val isReferencedByContentLengthParserExpressions: Boolean =
-    // TODO: should be for all root elements that are compiled in this
-    // schema compilation, such time as we allow more than one root element.
-    // Applies to all code that references the rootElementRef in this trait.
-    rootElementRef.get.contentLengthParserReferencedElementInfos.contains(this.dpathElementCompileInfo)
+  final lazy val shouldCaptureParseContentLength: Boolean = {
+    val isReferenced =
+      if (this.isInstanceOf[DetachedElementDecl]) false
+      else {
+        val setElems = rootElementRef.get.contentLengthParserReferencedElementInfos
+        setElems.contains(this.dpathElementCompileInfo)
+      }
+    isReferenced
+  }
 
   /**
    * Tells us if, for this element, we need to capture its content length
    *  at unparse runtime, or we can ignore that.
    */
-  final lazy val isReferencedByContentLengthUnparserExpressions: Boolean =
-    rootElementRef.get.contentLengthUnparserReferencedElementInfos.contains(this.dpathElementCompileInfo)
+  final lazy val shouldCaptureUnparseContentLength: Boolean = {
+    val isReferenced =
+      if (this.isInstanceOf[DetachedElementDecl]) false
+      else {
+        val setElems = rootElementRef.get.contentLengthUnparserReferencedElementInfos
+        setElems.contains(this.dpathElementCompileInfo)
+      }
+
+    // We need to capture content length when maybeFixedLengthInBits is
+    // defined because it allows us to set absolute start bit positions of
+    // the DOS, even when there are things like padding and OVC that can
+    // cause suspensions that result in relative bit positions. However, we
+    // really only need this if there are going to be suspensions, not on all
+    // fixed length elements. Otherwise, we're capturing content length for
+    // no reason (unless it is referenced in a contentLength expression).
+    val mightHaveSuspensions = (maybeFixedLengthInBits.isDefined && couldHaveSuspensions)
+
+    isReferenced || mightHaveSuspensions
+  }
 
   /**
    * Tells us if, for this element, we need to capture its value length
    *  at parse runtime, or we can ignore that.
    */
-  final lazy val isReferencedByValueLengthParserExpressions: Boolean = {
-    val setElems = rootElementRef.get.valueLengthParserReferencedElementInfos
-    //    if (this eq rootElement.get)
-    //      println("PARSER these are referenced by valueCalc: " + setElems.toString)
-    val res = setElems.contains(this.dpathElementCompileInfo)
-    res
+  final lazy val shouldCaptureParseValueLength: Boolean = {
+    val isReferenced =
+      if (this.isInstanceOf[DetachedElementDecl]) false
+      else {
+        val setElems = rootElementRef.get.valueLengthParserReferencedElementInfos
+        setElems.contains(this.dpathElementCompileInfo)
+      }
+
+    // For simple elements with text representation, valueLength is captured in
+    // individual parsers since they handle removing delimiters and padding.
+    //
+    // For complex elements with specified length, valueLength is captured in
+    // the specified length parsers, since they handle skipping unused
+    // element regions. For complex elements, this means lengthKind is not
+    // implicit or delimited.
+    //
+    // So for these cases we do not want to capture value length, since
+    // they are handled by the parsers as necessary
+    val capturedByParsers =
+      (isSimpleType && impliedRepresentation == Representation.Text) ||
+      (isComplexType && (lengthKind != LengthKind.Implicit && lengthKind != LengthKind.Delimited))
+
+    !capturedByParsers && isReferenced
   }
+
   /**
    * Tells us if, for this element, we need to capture its value length
    *  at unparse runtime, or we can ignore that.
    */
-  final lazy val isReferencedByValueLengthUnparserExpressions: Boolean = {
-    val setElems = rootElementRef.get.valueLengthUnparserReferencedElementInfos
-    //    if (this eq rootElement.get)
-    //      println("UNPARSER these are referenced by valueCalc: " + setElems.toString)
-    val isInExprs = setElems.contains(this.dpathElementCompileInfo)
-    val res = isInExprs ||
-      otherwiseShouldCaptureValueRegionLength
-    res
-  }
+  final lazy val shouldCaptureUnparseValueLength: Boolean = {
+    val isReferenced =
+      if (this.isInstanceOf[DetachedElementDecl]) false
+      else {
+        val setElems = rootElementRef.get.valueLengthUnparserReferencedElementInfos
+        setElems.contains(this.dpathElementCompileInfo)
+      }
 
-  /**
-   * Besides being referenced by the dfdl:valueLength function,
-   * We need the valueLength to be computed for unparser pad/fill, to check
-   * excess length, and for alignmentFills.
-   *
-   * TBD: why for alignment fills? Don't see using it in the code. Try without this?
-   */
-  private lazy val otherwiseShouldCaptureValueRegionLength: Boolean = {
+    // Besides being referenced by the dfdl:valueLength function,
+    // We need the valueLength to be computed for unparser pad/fill, to check
+    // excess length, and for alignmentFills.
+    //
+    // TBD: why for alignment fills? Don't see using it in the code. Try without this?
     val pad = this.shouldAddPadding
     val fill = this.shouldAddFill
     val len = this.shouldCheckExcessLength
     val alg = !this.isKnownToBeAligned // alignment fill uses the value length.
-    val res = pad || fill || len || alg
-    res
+    val mightHaveSuspensions = pad || fill || len || alg
+
+    isReferenced || mightHaveSuspensions
   }
 
   /**
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/LocalElementDecl.scala b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/LocalElementDecl.scala
index 923864d..b34b63a 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/LocalElementDecl.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/LocalElementDecl.scala
@@ -19,9 +19,9 @@ package org.apache.daffodil.dsom
 
 import scala.xml.Node
 
-final class LocalElementDecl(
+sealed class LocalElementDecl(
   final override val xml: Node,
-  final override val parent: GroupDefLike,
+  final override val parent: SchemaComponent,
   final override val position: Int)
   extends ElementBase
   with LocalElementComponentMixin
@@ -29,5 +29,20 @@ final class LocalElementDecl(
   with NestingLexicalMixin {
 
   requiredEvaluations(minOccurs, maxOccurs)
+}
 
+/**
+ * A DetachedElement is similar to a LocalElement except it will have no
+ * representation in the infoset, acting only as a temporary element that can
+ * be parsed/unparsed. As an example, this is used as an element foar
+ * parsing/unparsing prefix lengths. No element exists in the infoset or in the
+ * schema to represent a prefix length (only a simple type), so a
+ * DetachedElementDecl is used as a place where properties related to the
+ * prefix simpel type can be accessed.
+ */
+final class DetachedElementDecl(
+  val detachedReference: ElementBase,
+  xml: Node,
+  parent: SchemaComponent)
+  extends LocalElementDecl(xml, parent, -1){
 }
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/RuntimePropertyMixins.scala b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/RuntimePropertyMixins.scala
index 128146d..192655b 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/RuntimePropertyMixins.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/RuntimePropertyMixins.scala
@@ -32,6 +32,7 @@ import org.apache.daffodil.processors.InitiatorParseEv
 import org.apache.daffodil.processors.InitiatorUnparseEv
 import org.apache.daffodil.processors.OccursCountEv
 import org.apache.daffodil.processors.OutputNewLineEv
+import org.apache.daffodil.processors.Processor
 import org.apache.daffodil.processors.SeparatorParseEv
 import org.apache.daffodil.processors.SeparatorUnparseEv
 import org.apache.daffodil.processors.TerminatorParseEv
@@ -307,7 +308,7 @@ trait ElementRuntimeValuedPropertiesMixin
     else None
   }
 
-  protected final lazy val optLengthConstant: Option[Long] = {
+  final lazy val optLengthConstant: Option[Long] = {
     if (maybeLengthEv.isDefined) {
       lengthEv.optConstant.map { _.longValue }
     } else None
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/Term.scala b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/Term.scala
index 8f3ea08..859c8eb 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/dsom/Term.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/dsom/Term.scala
@@ -279,8 +279,8 @@ trait Term
       case c: ChoiceTermBase => Some(c)
       case s: SequenceTermBase => Some(s)
       case d: SchemaDocument => {
-        // we must be the Root elementRef
-        Assert.invariant(this.isInstanceOf[Root])
+        // we must be the Root elementRef or a detatched node
+        Assert.invariant(this.isInstanceOf[Root] || this.isInstanceOf[DetachedElementDecl])
         None
       }
       case gr: GroupRef => gr.asModelGroup.immediatelyEnclosingModelGroup
@@ -571,7 +571,7 @@ trait Term
         val elementCouldHaveSuspensions =
           commonCouldHaveSuspensions ||
             !isKnownToBeTextAligned || // MandatoryTextAlignmentUnparser
-            (if (eb.isSimpleType) eb.isOutputValueCalc else false) || // OVCRetryUnparser
+            (if (eb.isSimpleType) eb.isOutputValueCalc else false) || // SimpleTypeRetryUnparser
             eb.shouldAddFill || // ElementUnusedUnparser, RightFillUnparser
             eb.shouldCheckExcessLength || // ElementUnusedUnparser, RightFillUnparser
             eb.shouldAddPadding || // OnlyPaddingUnparser, RightCenteredPaddingUnparser, LeftCenteredPaddingUnparser
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/AlignedMixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/AlignedMixin.scala
index b64170d..69f7bf8 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/AlignedMixin.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/AlignedMixin.scala
@@ -20,6 +20,7 @@ package org.apache.daffodil.grammar
 import org.apache.daffodil.dsom.Term
 import org.apache.daffodil.dsom.ElementBase
 import org.apache.daffodil.dsom.ModelGroup
+import org.apache.daffodil.dsom.DetachedElementDecl
 import org.apache.daffodil.schema.annotation.props.gen.AlignmentUnits
 import org.apache.daffodil.schema.annotation.props.gen.LengthKind
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
@@ -125,8 +126,8 @@ trait AlignedMixin extends GrammarMixin { self: Term =>
   }
 
   private lazy val priorAlignmentApprox: AlignmentMultipleOf = {
-    if (this.isInstanceOf[Root]) {
-      AlignmentMultipleOf(0) // root is aligned with anything
+    if (this.isInstanceOf[Root] || this.isInstanceOf[DetachedElementDecl]) {
+      AlignmentMultipleOf(0) // root and detached elements are aligned with anything
     } else {
       val (priorSibs, parent) = potentialPriorTerms
       val arraySelfAlignment =
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/ElementBaseGrammarMixin.scala b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/ElementBaseGrammarMixin.scala
index 2821e19..48b1408 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/ElementBaseGrammarMixin.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/ElementBaseGrammarMixin.scala
@@ -25,6 +25,7 @@ import scala.Long
 import org.apache.daffodil.api.WarnID
 import org.apache.daffodil.dpath.NodeInfo
 import org.apache.daffodil.dpath.NodeInfo.PrimType
+import org.apache.daffodil.dsom.DetachedElementDecl
 import org.apache.daffodil.dsom.ElementBase
 import org.apache.daffodil.dsom.ExpressionCompilers
 import org.apache.daffodil.dsom.InitiatedTerminatedMixin
@@ -33,16 +34,21 @@ import org.apache.daffodil.exceptions.Assert
 import org.apache.daffodil.grammar.primitives.AlignmentFill
 import org.apache.daffodil.grammar.primitives.BCDDecimalDelimitedEndOfData
 import org.apache.daffodil.grammar.primitives.BCDDecimalKnownLength
+import org.apache.daffodil.grammar.primitives.BCDDecimalPrefixedLength
 import org.apache.daffodil.grammar.primitives.BCDDecimalRuntimeLength
 import org.apache.daffodil.grammar.primitives.BCDIntegerDelimitedEndOfData
 import org.apache.daffodil.grammar.primitives.BCDIntegerKnownLength
+import org.apache.daffodil.grammar.primitives.BCDIntegerPrefixedLength
 import org.apache.daffodil.grammar.primitives.BCDIntegerRuntimeLength
 import org.apache.daffodil.grammar.primitives.BinaryBoolean
+import org.apache.daffodil.grammar.primitives.BinaryBooleanPrefixedLength
 import org.apache.daffodil.grammar.primitives.BinaryDecimalKnownLength
+import org.apache.daffodil.grammar.primitives.BinaryDecimalPrefixedLength
 import org.apache.daffodil.grammar.primitives.BinaryDecimalRuntimeLength
 import org.apache.daffodil.grammar.primitives.BinaryDouble
 import org.apache.daffodil.grammar.primitives.BinaryFloat
 import org.apache.daffodil.grammar.primitives.BinaryIntegerKnownLength
+import org.apache.daffodil.grammar.primitives.BinaryIntegerPrefixedLength
 import org.apache.daffodil.grammar.primitives.BinaryIntegerRuntimeLength
 import org.apache.daffodil.grammar.primitives.CaptureContentLengthEnd
 import org.apache.daffodil.grammar.primitives.CaptureContentLengthStart
@@ -87,12 +93,15 @@ import org.apache.daffodil.grammar.primitives.ElementParseAndUnspecifiedLength
 import org.apache.daffodil.grammar.primitives.ElementUnused
 import org.apache.daffodil.grammar.primitives.HexBinaryDelimitedEndOfData
 import org.apache.daffodil.grammar.primitives.HexBinaryEndOfBitLimit
+import org.apache.daffodil.grammar.primitives.HexBinaryLengthPrefixed
 import org.apache.daffodil.grammar.primitives.HexBinarySpecifiedLength
 import org.apache.daffodil.grammar.primitives.IBM4690PackedDecimalDelimitedEndOfData
 import org.apache.daffodil.grammar.primitives.IBM4690PackedDecimalKnownLength
+import org.apache.daffodil.grammar.primitives.IBM4690PackedDecimalPrefixedLength
 import org.apache.daffodil.grammar.primitives.IBM4690PackedDecimalRuntimeLength
 import org.apache.daffodil.grammar.primitives.IBM4690PackedIntegerDelimitedEndOfData
 import org.apache.daffodil.grammar.primitives.IBM4690PackedIntegerKnownLength
+import org.apache.daffodil.grammar.primitives.IBM4690PackedIntegerPrefixedLength
 import org.apache.daffodil.grammar.primitives.IBM4690PackedIntegerRuntimeLength
 import org.apache.daffodil.grammar.primitives.Initiator
 import org.apache.daffodil.grammar.primitives.InputValueCalc
@@ -102,24 +111,27 @@ import org.apache.daffodil.grammar.primitives.LiteralCharacterNilOfSpecifiedLeng
 import org.apache.daffodil.grammar.primitives.LiteralNilDelimitedEndOfData
 import org.apache.daffodil.grammar.primitives.LiteralValueNilOfSpecifiedLength
 import org.apache.daffodil.grammar.primitives.LogicalNilValue
-import org.apache.daffodil.grammar.primitives.OVCRetry
 import org.apache.daffodil.grammar.primitives.OnlyPadding
 import org.apache.daffodil.grammar.primitives.PackedDecimalDelimitedEndOfData
 import org.apache.daffodil.grammar.primitives.PackedDecimalKnownLength
+import org.apache.daffodil.grammar.primitives.PackedDecimalPrefixedLength
 import org.apache.daffodil.grammar.primitives.PackedDecimalRuntimeLength
 import org.apache.daffodil.grammar.primitives.PackedIntegerDelimitedEndOfData
 import org.apache.daffodil.grammar.primitives.PackedIntegerKnownLength
+import org.apache.daffodil.grammar.primitives.PackedIntegerPrefixedLength
 import org.apache.daffodil.grammar.primitives.PackedIntegerRuntimeLength
 import org.apache.daffodil.grammar.primitives.PaddingInfoMixin
-import org.apache.daffodil.grammar.primitives.PrefixLength
 import org.apache.daffodil.grammar.primitives.RightCenteredPadding
 import org.apache.daffodil.grammar.primitives.RightFill
 import org.apache.daffodil.grammar.primitives.SimpleNilOrValue
+import org.apache.daffodil.grammar.primitives.SimpleTypeRetry
 import org.apache.daffodil.grammar.primitives.SpecifiedLengthExplicit
 import org.apache.daffodil.grammar.primitives.SpecifiedLengthExplicitCharacters
 import org.apache.daffodil.grammar.primitives.SpecifiedLengthImplicit
 import org.apache.daffodil.grammar.primitives.SpecifiedLengthImplicitCharacters
 import org.apache.daffodil.grammar.primitives.SpecifiedLengthPattern
+import org.apache.daffodil.grammar.primitives.SpecifiedLengthPrefixed
+import org.apache.daffodil.grammar.primitives.SpecifiedLengthPrefixedCharacters
 import org.apache.daffodil.grammar.primitives.StringDelimitedEndOfData
 import org.apache.daffodil.grammar.primitives.StringOfSpecifiedLength
 import org.apache.daffodil.grammar.primitives.Terminator
@@ -139,6 +151,7 @@ import org.apache.daffodil.schema.annotation.props.gen.TextNumberRep
 import org.apache.daffodil.schema.annotation.props.gen.YesNo
 import org.apache.daffodil.util.PackedSignCodes
 import org.apache.daffodil.xml.GlobalQName
+import org.apache.daffodil.xml.QName
 import org.apache.daffodil.xml.XMLUtils
 
 /////////////////////////////////////////////////////////////////
@@ -187,6 +200,79 @@ trait ElementBaseGrammarMixin
       minLen > 0)
   }
 
+  final lazy val prefixedLengthElementDecl: DetachedElementDecl = {
+    Assert.invariant(lengthKind == LengthKind.Prefixed)
+
+    // We need to resolve the global simple type of the prefix length type
+    // because we need to create a detached element with the same schema
+    // document/parent of the GSTD.
+    val prefixLengthTypeGSTD = schemaSet.getGlobalSimpleTypeDef(prefixLengthType).getOrElse(
+      schemaDefinitionError("Failed to resolve dfdl:prefixLengthType=\"%s\" to a simpleType", prefixLengthType.toQNameString)
+    )
+
+    val detachedNode = <element name={ name + " (prefixLength)" } type={ prefixLengthType.toQNameString } />.copy(scope = prefixLengthTypeGSTD.xml.scope)
+    val detachedElementDecl = new DetachedElementDecl(this, detachedNode, prefixLengthTypeGSTD.parent)
+
+    val prefixedLengthKind = detachedElementDecl.lengthKind
+    prefixedLengthKind match {
+      case LengthKind.Delimited | LengthKind.EndOfParent | LengthKind.Pattern =>
+        schemaDefinitionError("%s is specified as a dfdl:prefixLengthType, but has a dfdl:lengthKind of %s", prefixLengthType, prefixedLengthKind)
+      case LengthKind.Explicit if detachedElementDecl.optLengthConstant.isEmpty =>
+        schemaDefinitionError("%s is specified as a dfdl:prefixLengthType, but has an expression for dfdl:length", prefixLengthType)
+      case LengthKind.Implicit | LengthKind.Explicit if lengthUnits != detachedElementDecl.lengthUnits =>
+        schemaDefinitionError("%s is specified as a dfdl:prefixLengthType with dfdl:lengthKind %s, but has different dfdl:lengthUnits than the element", prefixLengthType, prefixedLengthKind)
+      case _ =>
+    }
+
+    schemaDefinitionUnless(detachedElementDecl.primType.isSubtypeOf(NodeInfo.Integer),
+      "%s is specified as a dfdl:prefixLengthType, but its type xs:%s is not a subtype of xs:integer", prefixLengthType, detachedElementDecl.primType.toString.toLowerCase)
+
+    schemaDefinitionWhen(detachedElementDecl.isOutputValueCalc,
+      "%s is specified as a dfdl:prefixLengthType, but specifies dfdl:outputValueCalc", prefixLengthType)
+    schemaDefinitionWhen(detachedElementDecl.hasInitiator,
+      "%s is specified as a dfdl:prefixLengthType, but specifies a dfdl:initiator", prefixLengthType)
+    schemaDefinitionWhen(detachedElementDecl.hasTerminator,
+      "%s is specified as a dfdl:prefixLengthType, but specifies a dfdl:terminator", prefixLengthType)
+    schemaDefinitionWhen(detachedElementDecl.alignment != 1,
+      "%s is specified as a dfdl:prefixLengthType, but specifies a dfdl:alignment other than 1", prefixLengthType)
+    schemaDefinitionWhen(detachedElementDecl.leadingSkip != 0,
+      "%s is specified as a dfdl:prefixLengthType, but specifies a dfdl:leadingSkip other than 0", prefixLengthType)
+    schemaDefinitionWhen(detachedElementDecl.trailingSkip != 0,
+      "%s is specified as a dfdl:prefixLengthType, but specifies a dfdl:trailingSkip other than 0", prefixLengthType)
+
+    if (detachedElementDecl.lengthKind == LengthKind.Prefixed &&
+        detachedElementDecl.prefixedLengthElementDecl.lengthKind == LengthKind.Prefixed) {
+        schemaDefinitionError("Nesting level for dfdl:prefixLengthType exceeds 1: %s > %s > %s > %s",
+          name, prefixLengthType,
+          detachedElementDecl.prefixLengthType,
+          detachedElementDecl.prefixedLengthElementDecl.prefixLengthType)
+    }
+
+    subset(detachedElementDecl.lengthKind != LengthKind.Prefixed, "Nested dfdl:lengthKind=\"prefixed\" is not supported.")
+
+    detachedElementDecl
+  }
+  final lazy val prefixedLengthAdjustmentInUnits: Long = prefixIncludesPrefixLength match {
+    case YesNo.Yes => {
+      // get the known length of the prefix element in lengthUnits
+      val pl = prefixedLengthElementDecl
+      pl.lengthKind match {
+        case LengthKind.Explicit => pl.lengthEv.optConstant.get // already in lengthUnits when explicit
+        case LengthKind.Implicit =>
+          Assert.invariant(impliedRepresentation == Representation.Binary)
+          val len = pl.lengthEv.optConstant.get // always in bits when implicit
+          pl.lengthUnits match {
+            case LengthUnits.Bits => len
+            case LengthUnits.Bytes => len / 8
+            case LengthUnits.Characters => Assert.impossible()
+          }
+        case _ => Assert.impossible()
+      }
+    }
+    case YesNo.No => 0
+  }
+  final lazy val prefixedLengthBody = prefixedLengthElementDecl.parsedValue
+
   /**
    * Quite tricky when we add padding or fill
    *
@@ -433,28 +519,39 @@ trait ElementBaseGrammarMixin
       CaptureContentLengthEnd(this)
   }
 
-  private lazy val parsedValue = prod("parsedValue", isSimpleType) {
+  lazy val parsedValue = prod("parsedValue", isSimpleType) {
     initiatorRegion ~
       valueMTA ~
-      captureLengthRegions(leftPadding, ovcRetry(value), rightPadding ~ rightFill) ~
+      captureLengthRegions(leftPadding, retrySimpleType(value), rightPadding ~ rightFill) ~
       terminatorRegion
   }
 
   /**
-   * Wrapped around the simple value unparsers used for dfdl:outputValueCalc (OVC)
-   * with a combinator. Will retry them until the value is available.
+   * Wrapped around the simple value unparsers where the simple type value is
+   * dynamic (e.g. prefixed length, dfdl:outputValueCalc). The correct parser
+   * will be inserted to retry until the simple type value is available.
    *
-   * Evaporates for parsing, and when the element is not dfdl:outputValueCalc.
+   * Evaporates for parsing, and when a dynamic simple type can't occur.
    *
    * Note: must be wrapped around the unparsed value only, not the framing.
    * Because some framing is alignment regions, which are themselves possibly
    * blocking/retrying. Setup of these must happen on the first pass, we cannot
    * do setups of ustate/data-output-streams when unparsing the result of an OVC.
    */
-  private def ovcRetry(allowedValueArg: => Gram) = {
+  private def retrySimpleType(allowedValueArg: => Gram) = {
     lazy val allowedValue = allowedValueArg
     if (this.isOutputValueCalc)
-      OVCRetry(this, allowedValue)
+      SimpleTypeRetry(this, allowedValue)
+    else if (this.isInstanceOf[DetachedElementDecl] &&
+             this.asInstanceOf[DetachedElementDecl].detachedReference.impliedRepresentation == Representation.Text)
+      // If an element has text representation and has a prefixed length, it
+      // means that the prefix length value will be calculated using a
+      // specified length unparser. This unparser works by suspending the
+      // prefix length unaprser, eventually calculating the length of the
+      // unaprsed data, then setting the length to the value of the detached
+      // element. Since the prefixed length unparser will need to suspend until
+      // its data value is dynaically set, it needs this SimpleTypeRetry.
+      SimpleTypeRetry(this, allowedValue)
     else
       allowedValue
   }
@@ -486,6 +583,7 @@ trait ElementBaseGrammarMixin
     case LengthKind.Implicit => implicitBinaryLengthInBits
     case LengthKind.Explicit if (lengthEv.isConstant) => explicitBinaryLengthInBits()
     case LengthKind.Explicit => -1 // means must be computed at runtime.
+    case LengthKind.Prefixed => -1 // means must be computed at runtime
     case LengthKind.Delimited => primType match {
       case PrimType.DateTime | PrimType.Date | PrimType.Time =>
         if (binaryCalendarRep == BinaryCalendarRep.BinaryMilliseconds || binaryCalendarRep == BinaryCalendarRep.BinarySeconds)
@@ -495,7 +593,6 @@ trait ElementBaseGrammarMixin
         else -1 // only for packed binary data, length must be computed at runtime.
     }
     case LengthKind.Pattern => schemaDefinitionError("Binary data elements cannot have lengthKind='pattern'.")
-    case LengthKind.Prefixed => subsetError("lengthKind='prefixed' not yet supported.")
     case LengthKind.EndOfParent => schemaDefinitionError("Binary data elements cannot have lengthKind='endOfParent'.")
   }
 
@@ -524,6 +621,7 @@ trait ElementBaseGrammarMixin
   private lazy val stringPrim = {
     lengthKind match {
       case LengthKind.Explicit => specifiedLength(StringOfSpecifiedLength(this))
+      case LengthKind.Prefixed => specifiedLength(StringOfSpecifiedLength(this))
       case LengthKind.Delimited => stringDelimitedEndOfData
       case LengthKind.Pattern => specifiedLength(StringOfSpecifiedLength(this))
       case LengthKind.Implicit => {
@@ -541,12 +639,16 @@ trait ElementBaseGrammarMixin
 
   private lazy val hexBinaryLengthPattern = prod("hexBinaryLengthPattern") { new SpecifiedLengthPattern(this, new HexBinaryEndOfBitLimit(this)) }
 
+  private lazy val hexBinaryLengthPrefixed = prod("hexBinaryLengthPrefixed") { new HexBinaryLengthPrefixed(this) }
+
   private lazy val hexBinaryValue = prod("hexBinaryValue") {
+    schemaDefinitionWhen(lengthUnits == LengthUnits.Characters, "Hex binary Numbers must have dfdl:lengthUnits of \"bits\" or \"bytes\".")
     lengthKind match {
       case LengthKind.Explicit => specifiedLengthHexBinary
       case LengthKind.Implicit => specifiedLengthHexBinary
       case LengthKind.Delimited => hexBinaryDelimitedEndOfData
       case LengthKind.Pattern => hexBinaryLengthPattern
+      case LengthKind.Prefixed => hexBinaryLengthPrefixed
       case LengthKind.EndOfParent if isComplexType => notYetImplemented("lengthKind='endOfParent' for complex type")
       case LengthKind.EndOfParent => notYetImplemented("lengthKind='endOfParent' for simple type")
       case _ => SDE("Unimplemented lengthKind %s", lengthKind)
@@ -657,6 +759,9 @@ trait ElementBaseGrammarMixin
   private lazy val bcdDelimitedLengthCalendar = prod("bcdDelimitedLengthCalendar", binaryCalendarRep == BinaryCalendarRep.Bcd) {
     bcdDateDelimitedLength || bcdTimeDelimitedLength || bcdDateTimeDelimitedLength
   }
+  private lazy val bcdPrefixedLengthCalendar = prod("bcdPrefixedLengthCalendar", binaryCalendarRep == BinaryCalendarRep.Bcd) {
+    bcdDatePrefixedLength || bcdTimePrefixedLength || bcdDateTimePrefixedLength
+  }
 
   // BCD calendar with known length
   private lazy val bcdDateKnownLength = prod("bcdDateKnownLength", primType == PrimType.Date) {
@@ -691,6 +796,17 @@ trait ElementBaseGrammarMixin
     ConvertZonedCombinator(this, new BCDIntegerDelimitedEndOfData(this), ConvertTextTimePrim(this))
   }
 
+  // BCD calendar with prefixed length
+  private lazy val bcdDatePrefixedLength = prod("bcdDatePrefixedLength", primType == PrimType.Date) {
+    ConvertZonedCombinator(this, new BCDIntegerPrefixedLength(this), ConvertTextDatePrim(this))
+  }
+  private lazy val bcdDateTimePrefixedLength = prod("bcdDateTimePrefixedLength", primType == PrimType.DateTime) {
+    ConvertZonedCombinator(this, new BCDIntegerPrefixedLength(this), ConvertTextDateTimePrim(this))
+  }
+  private lazy val bcdTimePrefixedLength = prod("bcdTimePrefixedLength", primType == PrimType.Time) {
+    ConvertZonedCombinator(this, new BCDIntegerPrefixedLength(this), ConvertTextTimePrim(this))
+  }
+
   private lazy val ibm4690PackedKnownLengthCalendar = prod("ibm4690PackedKnownLengthCalendar", binaryCalendarRep == BinaryCalendarRep.Ibm4690Packed) {
     ibm4690PackedDateKnownLength || ibm4690PackedTimeKnownLength || ibm4690PackedDateTimeKnownLength
   }
@@ -700,6 +816,9 @@ trait ElementBaseGrammarMixin
   private lazy val ibm4690PackedDelimitedLengthCalendar = prod("ibm4690PackedDelimitedLengthCalendar", binaryCalendarRep == BinaryCalendarRep.Ibm4690Packed) {
     ibm4690PackedDateDelimitedLength || ibm4690PackedTimeDelimitedLength || ibm4690PackedDateTimeDelimitedLength
   }
+  private lazy val ibm4690PackedPrefixedLengthCalendar = prod("ibm4690PackedPrefixedLengthCalendar", binaryCalendarRep == BinaryCalendarRep.Ibm4690Packed) {
+    ibm4690PackedDatePrefixedLength || ibm4690PackedTimePrefixedLength || ibm4690PackedDateTimePrefixedLength
+  }
 
   // ibm4690Packed calendar with known length
   private lazy val ibm4690PackedDateKnownLength = prod("ibm4690PackedDateKnownLength", primType == PrimType.Date) {
@@ -734,6 +853,17 @@ trait ElementBaseGrammarMixin
     ConvertZonedCombinator(this, new IBM4690PackedIntegerDelimitedEndOfData(this, false), ConvertTextTimePrim(this))
   }
 
+  // ibm4690Packed calendar with prefixed length
+  private lazy val ibm4690PackedDatePrefixedLength = prod("ibm4690PackedDatePrefixedLength", primType == PrimType.Date) {
+    ConvertZonedCombinator(this, new IBM4690PackedIntegerPrefixedLength(this, false), ConvertTextDatePrim(this))
+  }
+  private lazy val ibm4690PackedDateTimePrefixedLength = prod("ibm4690PackedDateTimePrefixedLength", primType == PrimType.DateTime) {
+    ConvertZonedCombinator(this, new IBM4690PackedIntegerPrefixedLength(this, false), ConvertTextDateTimePrim(this))
+  }
+  private lazy val ibm4690PackedTimePrefixedLength = prod("ibm4690PackedTimePrefixedLength", primType == PrimType.Time) {
+    ConvertZonedCombinator(this, new IBM4690PackedIntegerPrefixedLength(this, false), ConvertTextTimePrim(this))
+  }
+
   private lazy val packedKnownLengthCalendar = prod("packedKnownLengthCalendar", binaryCalendarRep == BinaryCalendarRep.Packed) {
     packedDateKnownLength || packedTimeKnownLength || packedDateTimeKnownLength
   }
@@ -743,6 +873,9 @@ trait ElementBaseGrammarMixin
   private lazy val packedDelimitedLengthCalendar = prod("packedDelimitedLengthCalendar", binaryCalendarRep == BinaryCalendarRep.Packed) {
     packedDateDelimitedLength || packedTimeDelimitedLength || packedDateTimeDelimitedLength
   }
+  private lazy val packedPrefixedLengthCalendar = prod("packedPrefixedLengthCalendar", binaryCalendarRep == BinaryCalendarRep.Packed) {
+    packedDatePrefixedLength || packedTimePrefixedLength || packedDateTimePrefixedLength
+  }
 
   // Packed calendar with known length
   private lazy val packedDateKnownLength = prod("packedDateKnownLength", primType == PrimType.Date) {
@@ -777,6 +910,17 @@ trait ElementBaseGrammarMixin
     ConvertZonedCombinator(this, new PackedIntegerDelimitedEndOfData(this, false, packedSignCodes), ConvertTextTimePrim(this))
   }
 
+  // Packed calendar with prefixed length
+  private lazy val packedDatePrefixedLength = prod("packedDatePrefixedLength", primType == PrimType.Date) {
+    ConvertZonedCombinator(this, new PackedIntegerPrefixedLength(this, false, packedSignCodes), ConvertTextDatePrim(this))
+  }
+  private lazy val packedDateTimePrefixedLength = prod("packedDateTimePrefixedLength", primType == PrimType.DateTime) {
+    ConvertZonedCombinator(this, new PackedIntegerPrefixedLength(this, false, packedSignCodes), ConvertTextDateTimePrim(this))
+  }
+  private lazy val packedTimePrefixedLength = prod("packedTimePrefixedLength", primType == PrimType.Time) {
+    ConvertZonedCombinator(this, new PackedIntegerPrefixedLength(this, false, packedSignCodes), ConvertTextTimePrim(this))
+  }
+
   private lazy val textDouble = prod("textDouble", impliedRepresentation == Representation.Text) {
     standardTextDouble || zonedTextDouble
   }
@@ -859,21 +1003,25 @@ trait ElementBaseGrammarMixin
       byteOrderRaw // must be defined or SDE
     }
     (binaryNumberRep, lengthKind, binaryNumberKnownLengthInBits) match {
+      case (BinaryNumberRep.Binary, LengthKind.Prefixed, _) => new BinaryIntegerPrefixedLength(this, isSigned)
       case (BinaryNumberRep.Binary, _, -1) => new BinaryIntegerRuntimeLength(this, isSigned)
       case (BinaryNumberRep.Binary, _, _) => new BinaryIntegerKnownLength(this, isSigned, binaryNumberKnownLengthInBits)
       case (_, LengthKind.Implicit, _) => SDE("lengthKind='implicit' is not allowed with packed binary formats")
       case (_, _, _) if ((binaryNumberKnownLengthInBits != -1) && (binaryNumberKnownLengthInBits % 4) != 0) =>
         SDE("The given length (%s bits) must be a multiple of 4 when using packed binary formats", binaryNumberKnownLengthInBits)
       case (BinaryNumberRep.Packed, LengthKind.Delimited, -1) => new PackedIntegerDelimitedEndOfData(this, isSigned, packedSignCodes)
+      case (BinaryNumberRep.Packed, LengthKind.Prefixed, -1) => new PackedIntegerPrefixedLength(this, isSigned, packedSignCodes)
       case (BinaryNumberRep.Packed, _, -1) => new PackedIntegerRuntimeLength(this, isSigned, packedSignCodes)
       case (BinaryNumberRep.Packed, _, _) => new PackedIntegerKnownLength(this, isSigned, packedSignCodes, binaryNumberKnownLengthInBits)
       case (BinaryNumberRep.Ibm4690Packed, LengthKind.Delimited, -1) => new IBM4690PackedIntegerDelimitedEndOfData(this, isSigned)
+      case (BinaryNumberRep.Ibm4690Packed, LengthKind.Prefixed, -1) => new IBM4690PackedIntegerPrefixedLength(this, isSigned)
       case (BinaryNumberRep.Ibm4690Packed, _, -1) => new IBM4690PackedIntegerRuntimeLength(this, isSigned)
       case (BinaryNumberRep.Ibm4690Packed, _, _) => new IBM4690PackedIntegerKnownLength(this, isSigned, binaryNumberKnownLengthInBits)
       case (BinaryNumberRep.Bcd, _, _) => primType match {
         case PrimType.Long | PrimType.Int | PrimType.Short | PrimType.Byte => SDE("%s is not an allowed type for bcd binary values", primType.name)
         case _ => (lengthKind, binaryNumberKnownLengthInBits) match {
           case (LengthKind.Delimited, -1) => new BCDIntegerDelimitedEndOfData(this)
+          case (LengthKind.Prefixed, -1) => new BCDIntegerPrefixedLength(this)
           case (_, -1) => new BCDIntegerRuntimeLength(this)
           case (_, _) => new BCDIntegerKnownLength(this, binaryNumberKnownLengthInBits)
         }
@@ -883,6 +1031,8 @@ trait ElementBaseGrammarMixin
 
   private lazy val binaryValue: Gram = {
     Assert.invariant(primType != PrimType.String)
+    
+    schemaDefinitionWhen(lengthUnits == LengthUnits.Characters, "Binary Numbers must have dfdl:lengthUnits of \"bits\" or \"bytes\".")
 
     // We have to dispatch carefully here. We cannot force evaluation of properties
     // that may not be necessary. E.g., float does not need property binaryNumberRep, so
@@ -921,24 +1071,33 @@ trait ElementBaseGrammarMixin
           binaryNumberKnownLengthInBits > 8) byteOrderRaw // must have or SDE
 
         (binaryNumberRep, lengthKind, binaryNumberKnownLengthInBits) match {
+          case (BinaryNumberRep.Binary, LengthKind.Prefixed, _) => new BinaryDecimalPrefixedLength(this)
           case (BinaryNumberRep.Binary, _, -1) => new BinaryDecimalRuntimeLength(this)
           case (BinaryNumberRep.Binary, _, _) => new BinaryDecimalKnownLength(this, binaryNumberKnownLengthInBits)
           case (_, LengthKind.Implicit, _) => SDE("lengthKind='implicit' is not allowed with packed binary formats")
           case (_, _, _) if ((binaryNumberKnownLengthInBits != -1) && (binaryNumberKnownLengthInBits % 4) != 0) =>
             SDE("The given length (%s bits) must be a multiple of 4 when using packed binary formats", binaryNumberKnownLengthInBits)
           case (BinaryNumberRep.Packed, LengthKind.Delimited, -1) => new PackedDecimalDelimitedEndOfData(this, packedSignCodes)
+          case (BinaryNumberRep.Packed, LengthKind.Prefixed, _) => new PackedDecimalPrefixedLength(this, packedSignCodes)
           case (BinaryNumberRep.Packed, _, -1) => new PackedDecimalRuntimeLength(this, packedSignCodes)
           case (BinaryNumberRep.Packed, _, _) => new PackedDecimalKnownLength(this, packedSignCodes, binaryNumberKnownLengthInBits)
           case (BinaryNumberRep.Bcd, LengthKind.Delimited, -1) => new BCDDecimalDelimitedEndOfData(this)
+          case (BinaryNumberRep.Bcd, LengthKind.Prefixed, _) => new BCDDecimalPrefixedLength(this)
           case (BinaryNumberRep.Bcd, _, -1) => new BCDDecimalRuntimeLength(this)
           case (BinaryNumberRep.Bcd, _, _) => new BCDDecimalKnownLength(this, binaryNumberKnownLengthInBits)
           case (BinaryNumberRep.Ibm4690Packed, LengthKind.Delimited, -1) => new IBM4690PackedDecimalDelimitedEndOfData(this)
+          case (BinaryNumberRep.Ibm4690Packed, LengthKind.Prefixed, _) => new IBM4690PackedDecimalPrefixedLength(this)
           case (BinaryNumberRep.Ibm4690Packed, _, -1) => new IBM4690PackedDecimalRuntimeLength(this)
           case (BinaryNumberRep.Ibm4690Packed, _, _) => new IBM4690PackedDecimalKnownLength(this, binaryNumberKnownLengthInBits)
         }
       }
 
-      case PrimType.Boolean => { new BinaryBoolean(this) }
+      case PrimType.Boolean => {
+        lengthKind match {
+          case LengthKind.Prefixed => new BinaryBooleanPrefixedLength(this)
+          case _ => new BinaryBoolean(this)
+        }
+      }
 
       case PrimType.DateTime | PrimType.Date | PrimType.Time => {
         (primType, binaryCalendarRep) match {
@@ -964,6 +1123,7 @@ trait ElementBaseGrammarMixin
               case (BinaryCalendarRep.Bcd) => {
                 (lengthKind, binaryNumberKnownLengthInBits) match {
                   case (LengthKind.Delimited, -1) => bcdDelimitedLengthCalendar
+                  case (LengthKind.Prefixed, -1) => bcdPrefixedLengthCalendar
                   case (_, -1) => bcdRuntimeLengthCalendar
                   case (_, _) => bcdKnownLengthCalendar
                 }
@@ -971,6 +1131,7 @@ trait ElementBaseGrammarMixin
               case (BinaryCalendarRep.Ibm4690Packed) => {
                 (lengthKind, binaryNumberKnownLengthInBits) match {
                   case (LengthKind.Delimited, -1) => ibm4690PackedDelimitedLengthCalendar
+                  case (LengthKind.Prefixed, -1) => ibm4690PackedPrefixedLengthCalendar
                   case (_, -1) => ibm4690PackedRuntimeLengthCalendar
                   case (_, _) => ibm4690PackedKnownLengthCalendar
                 }
@@ -978,6 +1139,7 @@ trait ElementBaseGrammarMixin
               case (BinaryCalendarRep.Packed) => {
                 (lengthKind, binaryNumberKnownLengthInBits) match {
                   case (LengthKind.Delimited, -1) => packedDelimitedLengthCalendar
+                  case (LengthKind.Prefixed, -1) => packedPrefixedLengthCalendar
                   case (_, -1) => packedRuntimeLengthCalendar
                   case (_, _) => packedKnownLengthCalendar
                 }
@@ -1086,7 +1248,7 @@ trait ElementBaseGrammarMixin
               LiteralValueNilOfSpecifiedLength(this)
             }
             case LengthKind.Implicit if isComplexType => Assert.invariantFailed("literal nil complex types aren't handled here.")
-            case LengthKind.Prefixed => notYetImplemented("lengthKind='prefixed'")
+            case LengthKind.Prefixed => LiteralValueNilOfSpecifiedLength(this)
             case LengthKind.EndOfParent if isComplexType => notYetImplemented("lengthKind='endOfParent' for complex type")
             case LengthKind.EndOfParent => notYetImplemented("lengthKind='endOfParent' for simple type")
           }
@@ -1149,6 +1311,13 @@ trait ElementBaseGrammarMixin
         Assert.invariant(lengthUnits eq LengthUnits.Characters)
         new SpecifiedLengthExplicitCharacters(this, body)
       }
+      case LengthKind.Prefixed if bitsMultiplier != 0 =>
+        new SpecifiedLengthPrefixed(this, body, bitsMultiplier)
+      case LengthKind.Prefixed => {
+        Assert.invariant(!knownEncodingIsFixedWidth)
+        Assert.invariant(lengthUnits eq LengthUnits.Characters)
+        new SpecifiedLengthPrefixedCharacters(this, body)
+      }
       case LengthKind.Implicit if isSimpleType && primType == PrimType.String &&
         encodingInfo.knownEncodingIsFixedWidth => {
         //
@@ -1169,7 +1338,7 @@ trait ElementBaseGrammarMixin
       case LengthKind.EndOfParent if isComplexType => notYetImplemented("lengthKind='endOfParent' for complex type")
       case LengthKind.EndOfParent => notYetImplemented("lengthKind='endOfParent' for simple type")
       case _ => {
-        // TODO: implement other specified length like prefixed and end of parent
+        // TODO: implement other specified length like end of parent
         // for now, no restriction
         body
       }
@@ -1203,7 +1372,7 @@ trait ElementBaseGrammarMixin
    * the element left framing does not include the initiator nor the element right framing the terminator
    */
   private lazy val alignAndSkipFraming = prod("alignAndSkipFraming") {
-    LeadingSkipRegion(this) ~ AlignmentFill(this) ~ PrefixLength(this)
+    LeadingSkipRegion(this) ~ AlignmentFill(this)
   }
 
   private lazy val elementLeftFraming = alignAndSkipFraming
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ElementCombinator.scala b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ElementCombinator.scala
index 27e78d0..d4cdc6e 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ElementCombinator.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ElementCombinator.scala
@@ -42,7 +42,7 @@ import org.apache.daffodil.processors.unparsers.ElementUnparserNoRep
 import org.apache.daffodil.processors.unparsers.ElementUnspecifiedLengthUnparser
 import org.apache.daffodil.processors.unparsers.ElementUnusedUnparser
 import org.apache.daffodil.processors.unparsers.LeftCenteredPaddingUnparser
-import org.apache.daffodil.processors.unparsers.OVCRetryUnparser
+import org.apache.daffodil.processors.unparsers.SimpleTypeRetryUnparser
 import org.apache.daffodil.processors.unparsers.OnlyPaddingUnparser
 import org.apache.daffodil.processors.unparsers.RightCenteredPaddingUnparser
 import org.apache.daffodil.processors.unparsers.RightFillUnparser
@@ -214,11 +214,11 @@ case class RightFill(ctxt: ElementBase)
     unparsingPadChar)
 }
 
-case class OVCRetry(ctxt: ElementBase, v: Gram)
+case class SimpleTypeRetry(ctxt: ElementBase, v: Gram)
   extends Terminal(ctxt, true) {
   override def parser = v.parser
 
-  override def unparser = new OVCRetryUnparser(
+  override def unparser = new SimpleTypeRetryUnparser(
     ctxt.erd,
     ctxt.maybeUnparseTargetLengthInBitsEv, v.unparser)
 }
@@ -226,23 +226,13 @@ case class OVCRetry(ctxt: ElementBase, v: Gram)
 case class CaptureContentLengthStart(ctxt: ElementBase)
   extends Terminal(ctxt, true) {
   override def parser =
-    if (ctxt.isReferencedByContentLengthParserExpressions)
+    if (ctxt.shouldCaptureParseContentLength)
       new CaptureStartOfContentLengthParser(ctxt.erd)
     else
       new NadaParser(ctxt.erd)
 
   override lazy val unparser: Unparser =
-    // TODO: This content length start is added when maybeFixedLengthInBits is
-    // defined because it allows us to set absolute start bit positions of the
-    // DOS, even when there are things like padding and OVC that can cause
-    // suspensions that result in relative bit positions. However, we really
-    // only need this if there are going to be suspensions, not on all fixed
-    // length elements. Otherwise, we're capturing content length for no reason
-    // (unless it is referenced in a contentLength expression). We should
-    // improve this check so that this unparser can be optimized out if there
-    // will not be any suspensions.
-    if (ctxt.isReferencedByContentLengthUnparserExpressions ||
-      (ctxt.maybeFixedLengthInBits.isDefined && ctxt.couldHaveSuspensions))
+    if (ctxt.shouldCaptureUnparseContentLength)
       new CaptureStartOfContentLengthUnparser(ctxt.erd)
     else
       new NadaUnparser(ctxt.erd)
@@ -251,23 +241,13 @@ case class CaptureContentLengthStart(ctxt: ElementBase)
 case class CaptureContentLengthEnd(ctxt: ElementBase)
   extends Terminal(ctxt, true) {
   override def parser =
-    if (ctxt.isReferencedByContentLengthParserExpressions)
+    if (ctxt.shouldCaptureParseContentLength)
       new CaptureEndOfContentLengthParser(ctxt.erd)
     else
       new NadaParser(ctxt.erd)
 
   override lazy val unparser: Unparser =
-    // TODO: This content length start is added when maybeFixedLengthInBits is
-    // defined because it allows us to set absolute start bit positions of the
-    // DOS, even when there are things like padding and OVC that can cause
-    // suspensions that result in relative bit positions. However, we really
-    // only need this if there are going to be suspensions, not on all fixed
-    // length elements. Otherwise, we're capturing content length for no reason
-    // (unless it is referenced in a contentLength expression). We should
-    // improve this check so that this unparser can be optimized out if there
-    // will not be any suspensions.
-    if (ctxt.isReferencedByContentLengthUnparserExpressions ||
-      (ctxt.maybeFixedLengthInBits.isDefined && ctxt.couldHaveSuspensions))
+    if (ctxt.shouldCaptureUnparseContentLength)
       new CaptureEndOfContentLengthUnparser(ctxt.erd, ctxt.maybeFixedLengthInBits)
     else
       new NadaUnparser(ctxt.erd)
@@ -276,62 +256,33 @@ case class CaptureContentLengthEnd(ctxt: ElementBase)
 case class CaptureValueLengthStart(ctxt: ElementBase)
   extends Terminal(ctxt, true) {
   override def parser =
-    if (ctxt.isReferencedByValueLengthParserExpressions) {
-      // For simple elements with text representation, valueLength is captured in
-      // individual parsers since they handle removing delimiters and padding.
-      //
-      // For complex elements with specified length, valueLength is captured in
-      // the specified length parsers, since they handle skipping unused
-      // element regions. For complex elements, this means lengthKind is not
-      // implicit or delimited.
-      //
-      // For all other elements, we can just use the Capture*ValueLength parsers.
-      if ((ctxt.isSimpleType && ctxt.impliedRepresentation == Representation.Text) ||
-        (ctxt.isComplexType && (ctxt.lengthKind != LengthKind.Implicit && ctxt.lengthKind != LengthKind.Delimited)))
-        new NadaParser(ctxt.erd)
-      else
-        new CaptureStartOfValueLengthParser(ctxt.erd)
-    } else
+    if (ctxt.shouldCaptureParseValueLength)
+      new CaptureStartOfValueLengthParser(ctxt.erd)
+    else
       new NadaParser(ctxt.erd)
 
   override lazy val unparser: Unparser =
-    if (ctxt.isReferencedByValueLengthUnparserExpressions) {
+    if (ctxt.shouldCaptureUnparseValueLength)
       new CaptureStartOfValueLengthUnparser(ctxt.erd)
-    } else
+    else
       new NadaUnparser(ctxt.erd)
 }
 
 case class CaptureValueLengthEnd(ctxt: ElementBase)
   extends Terminal(ctxt, true) {
   override def parser =
-    if (ctxt.isReferencedByValueLengthParserExpressions) {
-      // For simple elements with text representation, valueLength is captured in
-      // individual parsers since they handle removing delimiters and padding.
-      //
-      // For complex elements with specified length, valueLength is captured in
-      // the specified length parsers, since they handle skipping unused
-      // element regions. For complex elements, this means lengthKind is not
-      // implicit or delimited.
-      //
-      // For all other elements, we can just use the Capture*ValueLength parsers.
-      if ((ctxt.isSimpleType && ctxt.impliedRepresentation == Representation.Text) ||
-        (ctxt.isComplexType && (ctxt.lengthKind != LengthKind.Implicit && ctxt.lengthKind != LengthKind.Delimited)))
-        new NadaParser(ctxt.erd)
-      else
-        new CaptureEndOfValueLengthParser(ctxt.erd)
-    } else
+    if (ctxt.shouldCaptureParseValueLength)
+      new CaptureEndOfValueLengthParser(ctxt.erd)
+    else
       new NadaParser(ctxt.erd)
 
   override lazy val unparser: Unparser =
-    if (ctxt.isReferencedByValueLengthUnparserExpressions) {
+    if (ctxt.shouldCaptureUnparseValueLength)
       new CaptureEndOfValueLengthUnparser(ctxt.erd)
-    } else
+    else
       new NadaUnparser(ctxt.erd)
 }
 
-/*
- * new stuff for specified length unparsing above here.
- */
 
 class ElementParseAndUnspecifiedLength(context: ElementBase, eBeforeGram: Gram, eGram: Gram, eAfterGram: Gram)
   extends ElementCombinatorBase(context, eBeforeGram, eGram, eAfterGram) {
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBCD.scala b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBCD.scala
index 27560f0..94d0400 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBCD.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBCD.scala
@@ -17,17 +17,22 @@
 
 package org.apache.daffodil.grammar.primitives
 
-import org.apache.daffodil.grammar.Terminal
 import org.apache.daffodil.dsom.ElementBase
-import org.apache.daffodil.processors.parsers.BCDIntegerRuntimeLengthParser
-import org.apache.daffodil.processors.parsers.BCDIntegerKnownLengthParser
-import org.apache.daffodil.processors.parsers.BCDDecimalRuntimeLengthParser
+import org.apache.daffodil.grammar.Terminal
 import org.apache.daffodil.processors.parsers.BCDDecimalKnownLengthParser
-import org.apache.daffodil.processors.unparsers.Unparser
-import org.apache.daffodil.processors.unparsers.BCDIntegerRuntimeLengthUnparser
-import org.apache.daffodil.processors.unparsers.BCDIntegerKnownLengthUnparser
-import org.apache.daffodil.processors.unparsers.BCDDecimalRuntimeLengthUnparser
+import org.apache.daffodil.processors.parsers.BCDDecimalPrefixedLengthParser
+import org.apache.daffodil.processors.parsers.BCDDecimalRuntimeLengthParser
+import org.apache.daffodil.processors.parsers.BCDIntegerKnownLengthParser
+import org.apache.daffodil.processors.parsers.BCDIntegerPrefixedLengthParser
+import org.apache.daffodil.processors.parsers.BCDIntegerRuntimeLengthParser
 import org.apache.daffodil.processors.unparsers.BCDDecimalKnownLengthUnparser
+import org.apache.daffodil.processors.unparsers.BCDDecimalPrefixedLengthUnparser
+import org.apache.daffodil.processors.unparsers.BCDDecimalRuntimeLengthUnparser
+import org.apache.daffodil.processors.unparsers.BCDIntegerKnownLengthUnparser
+import org.apache.daffodil.processors.unparsers.BCDIntegerPrefixedLengthUnparser
+import org.apache.daffodil.processors.unparsers.BCDIntegerRuntimeLengthUnparser
+import org.apache.daffodil.processors.unparsers.Unparser
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
 
 class BCDIntegerRuntimeLength(val e: ElementBase) extends Terminal(e, true) {
   override lazy val parser = new BCDIntegerRuntimeLengthParser(e.elementRuntimeData, e.lengthEv, e.lengthUnits)
@@ -42,6 +47,24 @@ class BCDIntegerKnownLength(val e: ElementBase, lengthInBits: Long) extends Term
   override lazy val unparser: Unparser = new BCDIntegerKnownLengthUnparser(e.elementRuntimeData, lengthInBits.toInt)
 }
 
+class BCDIntegerPrefixedLength(val e: ElementBase) extends Terminal(e, true) {
+
+  override lazy val parser = new BCDIntegerPrefixedLengthParser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.parser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+
+  override lazy val unparser: Unparser = new BCDIntegerPrefixedLengthUnparser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.unparser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+}
+
+
 class BCDDecimalRuntimeLength(val e: ElementBase) extends Terminal(e, true) {
   override lazy val parser = new BCDDecimalRuntimeLengthParser(e.elementRuntimeData, e.binaryDecimalVirtualPoint, e.lengthEv, e.lengthUnits)
 
@@ -54,3 +77,23 @@ class BCDDecimalKnownLength(val e: ElementBase, lengthInBits: Long) extends Term
 
   override lazy val unparser: Unparser = new BCDDecimalKnownLengthUnparser(e.elementRuntimeData, e.binaryDecimalVirtualPoint, lengthInBits.toInt)
 }
+
+class BCDDecimalPrefixedLength(val e: ElementBase) extends Terminal(e, true) {
+
+  override lazy val parser = new BCDDecimalPrefixedLengthParser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.parser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.binaryDecimalVirtualPoint,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+
+  override lazy val unparser: Unparser = new BCDDecimalPrefixedLengthUnparser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.unparser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.binaryDecimalVirtualPoint,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+}
+
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBinaryBoolean.scala b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBinaryBoolean.scala
index 617458d..809bd42 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBinaryBoolean.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBinaryBoolean.scala
@@ -20,11 +20,33 @@ package org.apache.daffodil.grammar.primitives
 import org.apache.daffodil.grammar.Terminal
 import org.apache.daffodil.dsom.ElementBase
 import org.apache.daffodil.processors.parsers.BinaryBooleanParser
+import org.apache.daffodil.processors.parsers.BinaryBooleanPrefixedLengthParser
 import org.apache.daffodil.processors.unparsers.Unparser
 import org.apache.daffodil.processors.unparsers.BinaryBooleanUnparser
+import org.apache.daffodil.processors.unparsers.BinaryBooleanPrefixedLengthUnparser
 
 class BinaryBoolean(val e: ElementBase) extends Terminal(e, true) {
   override lazy val parser = new BinaryBooleanParser(e.elementRuntimeData, e.binaryBooleanTrueRep, e.binaryBooleanFalseRep, e.lengthEv, e.lengthUnits, e.lengthKind)
 
   override lazy val unparser: Unparser = new BinaryBooleanUnparser(e.elementRuntimeData, e.binaryBooleanTrueRep, e.binaryBooleanFalseRep, e.lengthEv, e.lengthUnits, e.lengthKind)
 }
+
+class BinaryBooleanPrefixedLength(val e: ElementBase) extends Terminal(e, true) {
+  override lazy val parser = new BinaryBooleanPrefixedLengthParser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.parser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.binaryBooleanTrueRep,
+    e.binaryBooleanFalseRep,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+
+  override lazy val unparser: Unparser = new BinaryBooleanPrefixedLengthUnparser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.unparser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.binaryBooleanTrueRep,
+    e.binaryBooleanFalseRep,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+}
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBinaryNumber.scala b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBinaryNumber.scala
index 4bc92a6..d328c3d 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBinaryNumber.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesBinaryNumber.scala
@@ -17,21 +17,29 @@
 
 package org.apache.daffodil.grammar.primitives
 
-import org.apache.daffodil.grammar.Terminal
+import org.apache.daffodil.dpath.NodeInfo
 import org.apache.daffodil.dsom.ElementBase
-import org.apache.daffodil.processors.parsers.BinaryIntegerRuntimeLengthParser
-import org.apache.daffodil.processors.parsers.BinaryIntegerKnownLengthParser
-import org.apache.daffodil.processors.parsers.BinaryDecimalRuntimeLengthParser
+import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.grammar.Terminal
 import org.apache.daffodil.processors.parsers.BinaryDecimalKnownLengthParser
-import org.apache.daffodil.processors.parsers.BinaryFloatParser
+import org.apache.daffodil.processors.parsers.BinaryDecimalPrefixedLengthParser
+import org.apache.daffodil.processors.parsers.BinaryDecimalRuntimeLengthParser
 import org.apache.daffodil.processors.parsers.BinaryDoubleParser
-import org.apache.daffodil.processors.unparsers.Unparser
-import org.apache.daffodil.processors.unparsers.BinaryIntegerKnownLengthUnparser
-import org.apache.daffodil.processors.unparsers.BinaryIntegerRuntimeLengthUnparser
-import org.apache.daffodil.processors.unparsers.BinaryDecimalRuntimeLengthUnparser
+import org.apache.daffodil.processors.parsers.BinaryFloatParser
+import org.apache.daffodil.processors.parsers.BinaryIntegerKnownLengthParser
+import org.apache.daffodil.processors.parsers.BinaryIntegerPrefixedLengthParser
+import org.apache.daffodil.processors.parsers.BinaryIntegerRuntimeLengthParser
 import org.apache.daffodil.processors.unparsers.BinaryDecimalKnownLengthUnparser
+import org.apache.daffodil.processors.unparsers.BinaryDecimalPrefixedLengthUnparser
+import org.apache.daffodil.processors.unparsers.BinaryDecimalRuntimeLengthUnparser
 import org.apache.daffodil.processors.unparsers.BinaryDoubleUnparser
 import org.apache.daffodil.processors.unparsers.BinaryFloatUnparser
+import org.apache.daffodil.processors.unparsers.BinaryIntegerKnownLengthUnparser
+import org.apache.daffodil.processors.unparsers.BinaryIntegerRuntimeLengthUnparser
+import org.apache.daffodil.processors.unparsers.BinaryIntegerPrefixedLengthUnparser
+import org.apache.daffodil.processors.unparsers.Unparser
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.util.MaybeInt
 
 class BinaryIntegerRuntimeLength(val e: ElementBase, signed: Boolean) extends Terminal(e, true) {
 
@@ -49,6 +57,37 @@ class BinaryIntegerKnownLength(val e: ElementBase, signed: Boolean, lengthInBits
   override lazy val unparser: Unparser = new BinaryIntegerKnownLengthUnparser(e.elementRuntimeData, signed, lengthInBits.toInt)
 }
 
+class BinaryIntegerPrefixedLength(val e: ElementBase, signed: Boolean) extends Terminal(e, true) {
+
+  override lazy val parser =
+    new BinaryIntegerPrefixedLengthParser(
+      e.elementRuntimeData,
+      e.prefixedLengthBody.parser,
+      e.prefixedLengthElementDecl.elementRuntimeData,
+      signed,
+      e.lengthUnits,
+      e.prefixedLengthAdjustmentInUnits)
+
+  override lazy val unparser: Unparser = {
+    val maybeNBits = e.primType match {
+      case NodeInfo.Long | NodeInfo.UnsignedLong => MaybeInt(64)
+      case NodeInfo.Int | NodeInfo.UnsignedInt => MaybeInt(32)
+      case NodeInfo.Short | NodeInfo.UnsignedShort => MaybeInt(16)
+      case NodeInfo.Byte | NodeInfo.UnsignedByte => MaybeInt(8)
+      case NodeInfo.Integer | NodeInfo.NonNegativeInteger => MaybeInt.Nope
+      case _ => Assert.invariantFailed("Only integer base types should be used for this primitive")
+    }
+    new BinaryIntegerPrefixedLengthUnparser(
+      e.elementRuntimeData,
+      e.prefixedLengthBody.unparser,
+      e.prefixedLengthElementDecl.elementRuntimeData,
+      maybeNBits,
+      signed,
+      e.lengthUnits,
+      e.prefixedLengthAdjustmentInUnits)
+  }
+}
+
 class BinaryDecimalRuntimeLength(val e: ElementBase) extends Terminal(e, true) {
 
   override lazy val parser = new BinaryDecimalRuntimeLengthParser(e.elementRuntimeData, e.decimalSigned, e.binaryDecimalVirtualPoint, e.lengthEv, e.lengthUnits)
@@ -64,6 +103,30 @@ class BinaryDecimalKnownLength(val e: ElementBase, lengthInBits: Long) extends T
   override lazy val unparser: Unparser = new BinaryDecimalKnownLengthUnparser(e.elementRuntimeData, e.decimalSigned, e.binaryDecimalVirtualPoint, lengthInBits.toInt)
 }
 
+class BinaryDecimalPrefixedLength(val e: ElementBase) extends Terminal(e, true) {
+
+  override lazy val parser =
+    new BinaryDecimalPrefixedLengthParser(
+      e.elementRuntimeData,
+      e.prefixedLengthBody.parser,
+      e.prefixedLengthElementDecl.elementRuntimeData,
+      e.decimalSigned,
+      e.binaryDecimalVirtualPoint,
+      e.lengthUnits,
+      e.prefixedLengthAdjustmentInUnits)
+
+  override lazy val unparser: Unparser =
+    new BinaryDecimalPrefixedLengthUnparser(
+      e.elementRuntimeData,
+      e.prefixedLengthBody.unparser,
+      e.prefixedLengthElementDecl.elementRuntimeData,
+      e.decimalSigned,
+      e.binaryDecimalVirtualPoint,
+      e.lengthUnits,
+      e.prefixedLengthAdjustmentInUnits)
+
+}
+
 class BinaryFloat(val e: ElementBase) extends Terminal(e, true) {
 
   override lazy val parser = new BinaryFloatParser(e.elementRuntimeData)
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesIBM4690Packed.scala b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesIBM4690Packed.scala
index 1039769..677845a 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesIBM4690Packed.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesIBM4690Packed.scala
@@ -17,17 +17,22 @@
 
 package org.apache.daffodil.grammar.primitives
 
-import org.apache.daffodil.grammar.Terminal
 import org.apache.daffodil.dsom.ElementBase
-import org.apache.daffodil.processors.parsers.IBM4690PackedIntegerRuntimeLengthParser
-import org.apache.daffodil.processors.parsers.IBM4690PackedIntegerKnownLengthParser
-import org.apache.daffodil.processors.parsers.IBM4690PackedDecimalRuntimeLengthParser
+import org.apache.daffodil.grammar.Terminal
 import org.apache.daffodil.processors.parsers.IBM4690PackedDecimalKnownLengthParser
-import org.apache.daffodil.processors.unparsers.Unparser
-import org.apache.daffodil.processors.unparsers.IBM4690PackedIntegerRuntimeLengthUnparser
-import org.apache.daffodil.processors.unparsers.IBM4690PackedIntegerKnownLengthUnparser
-import org.apache.daffodil.processors.unparsers.IBM4690PackedDecimalRuntimeLengthUnparser
+import org.apache.daffodil.processors.parsers.IBM4690PackedDecimalPrefixedLengthParser
+import org.apache.daffodil.processors.parsers.IBM4690PackedDecimalRuntimeLengthParser
+import org.apache.daffodil.processors.parsers.IBM4690PackedIntegerKnownLengthParser
+import org.apache.daffodil.processors.parsers.IBM4690PackedIntegerPrefixedLengthParser
+import org.apache.daffodil.processors.parsers.IBM4690PackedIntegerRuntimeLengthParser
 import org.apache.daffodil.processors.unparsers.IBM4690PackedDecimalKnownLengthUnparser
+import org.apache.daffodil.processors.unparsers.IBM4690PackedDecimalPrefixedLengthUnparser
+import org.apache.daffodil.processors.unparsers.IBM4690PackedDecimalRuntimeLengthUnparser
+import org.apache.daffodil.processors.unparsers.IBM4690PackedIntegerKnownLengthUnparser
+import org.apache.daffodil.processors.unparsers.IBM4690PackedIntegerPrefixedLengthUnparser
+import org.apache.daffodil.processors.unparsers.IBM4690PackedIntegerRuntimeLengthUnparser
+import org.apache.daffodil.processors.unparsers.Unparser
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
 
 class IBM4690PackedIntegerRuntimeLength(val e: ElementBase, signed: Boolean) extends Terminal(e, true) {
   override lazy val parser = new IBM4690PackedIntegerRuntimeLengthParser(e.elementRuntimeData, signed, e.lengthEv, e.lengthUnits)
@@ -42,6 +47,23 @@ class IBM4690PackedIntegerKnownLength(val e: ElementBase, signed: Boolean, lengt
   override lazy val unparser: Unparser = new IBM4690PackedIntegerKnownLengthUnparser(e.elementRuntimeData, lengthInBits.toInt)
 }
 
+class IBM4690PackedIntegerPrefixedLength(val e: ElementBase, signed: Boolean) extends Terminal(e, true) {
+  override lazy val parser = new IBM4690PackedIntegerPrefixedLengthParser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.parser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    signed,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+
+  override lazy val unparser: Unparser = new IBM4690PackedIntegerPrefixedLengthUnparser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.unparser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+}
+
 class IBM4690PackedDecimalRuntimeLength(val e: ElementBase) extends Terminal(e, true) {
   override lazy val parser = new IBM4690PackedDecimalRuntimeLengthParser(e.elementRuntimeData, e.binaryDecimalVirtualPoint, e.lengthEv, e.lengthUnits)
 
@@ -55,3 +77,21 @@ class IBM4690PackedDecimalKnownLength(val e: ElementBase, lengthInBits: Long) ex
   override lazy val unparser: Unparser = new IBM4690PackedDecimalKnownLengthUnparser(e.elementRuntimeData, e.binaryDecimalVirtualPoint, lengthInBits.toInt)
 }
 
+
+class IBM4690PackedDecimalPrefixedLength(val e: ElementBase) extends Terminal(e, true) {
+  override lazy val parser = new IBM4690PackedDecimalPrefixedLengthParser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.parser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.binaryDecimalVirtualPoint,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+
+  override lazy val unparser: Unparser = new IBM4690PackedDecimalPrefixedLengthUnparser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.unparser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.binaryDecimalVirtualPoint,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+}
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesLengthKind.scala b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesLengthKind.scala
index b2d9dfd..95fa4ef 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesLengthKind.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesLengthKind.scala
@@ -18,35 +18,40 @@
 package org.apache.daffodil.grammar.primitives
 
 import scala.Boolean
+
 import org.apache.daffodil.dsom.ElementBase
 import org.apache.daffodil.dsom.Term
 import org.apache.daffodil.grammar.Gram
 import org.apache.daffodil.grammar.Terminal
+import org.apache.daffodil.processors.FieldDFAParseEv
+import org.apache.daffodil.processors.TextTruncationType
 import org.apache.daffodil.processors.dfa.TextDelimitedParser
 import org.apache.daffodil.processors.dfa.TextDelimitedParserWithEscapeBlock
 import org.apache.daffodil.processors.dfa.TextPaddingParser
+import org.apache.daffodil.processors.parsers.BCDDecimalDelimitedParser
+import org.apache.daffodil.processors.parsers.BCDIntegerDelimitedParser
 import org.apache.daffodil.processors.parsers.HexBinaryDelimitedParser
 import org.apache.daffodil.processors.parsers.HexBinaryEndOfBitLimitParser
+import org.apache.daffodil.processors.parsers.HexBinaryLengthPrefixedParser
 import org.apache.daffodil.processors.parsers.HexBinarySpecifiedLengthParser
-import org.apache.daffodil.processors.parsers.PackedIntegerDelimitedParser
-import org.apache.daffodil.processors.parsers.PackedDecimalDelimitedParser
-import org.apache.daffodil.processors.parsers.BCDIntegerDelimitedParser
-import org.apache.daffodil.processors.parsers.BCDDecimalDelimitedParser
-import org.apache.daffodil.processors.parsers.IBM4690PackedIntegerDelimitedParser
 import org.apache.daffodil.processors.parsers.IBM4690PackedDecimalDelimitedParser
+import org.apache.daffodil.processors.parsers.IBM4690PackedIntegerDelimitedParser
 import org.apache.daffodil.processors.parsers.LiteralNilDelimitedEndOfDataParser
+import org.apache.daffodil.processors.parsers.PackedDecimalDelimitedParser
+import org.apache.daffodil.processors.parsers.PackedIntegerDelimitedParser
 import org.apache.daffodil.processors.parsers.StringDelimitedParser
 import org.apache.daffodil.processors.parsers.StringOfSpecifiedLengthParser
 import org.apache.daffodil.processors.parsers.{ Parser => DaffodilParser }
-import org.apache.daffodil.processors.unparsers.HexBinaryMinLengthInBytesUnparser
-import org.apache.daffodil.processors.unparsers.PackedIntegerDelimitedUnparser
-import org.apache.daffodil.processors.unparsers.PackedDecimalDelimitedUnparser
-import org.apache.daffodil.processors.unparsers.BCDIntegerDelimitedUnparser
 import org.apache.daffodil.processors.unparsers.BCDDecimalDelimitedUnparser
-import org.apache.daffodil.processors.unparsers.IBM4690PackedIntegerDelimitedUnparser
-import org.apache.daffodil.processors.unparsers.IBM4690PackedDecimalDelimitedUnparser
+import org.apache.daffodil.processors.unparsers.BCDIntegerDelimitedUnparser
+import org.apache.daffodil.processors.unparsers.HexBinaryLengthPrefixedUnparser
+import org.apache.daffodil.processors.unparsers.HexBinaryMinLengthInBytesUnparser
 import org.apache.daffodil.processors.unparsers.HexBinarySpecifiedLengthUnparser
+import org.apache.daffodil.processors.unparsers.IBM4690PackedDecimalDelimitedUnparser
+import org.apache.daffodil.processors.unparsers.IBM4690PackedIntegerDelimitedUnparser
 import org.apache.daffodil.processors.unparsers.LiteralNilDelimitedEndOfDataUnparser
+import org.apache.daffodil.processors.unparsers.PackedDecimalDelimitedUnparser
+import org.apache.daffodil.processors.unparsers.PackedIntegerDelimitedUnparser
 import org.apache.daffodil.processors.unparsers.StringDelimitedUnparser
 import org.apache.daffodil.processors.unparsers.StringMaybeTruncateBitsUnparser
 import org.apache.daffodil.processors.unparsers.StringMaybeTruncateCharactersUnparser
@@ -58,8 +63,6 @@ import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
 import org.apache.daffodil.util.Maybe.Nope
 import org.apache.daffodil.util.Maybe.One
 import org.apache.daffodil.util.PackedSignCodes
-import org.apache.daffodil.processors.FieldDFAParseEv
-import org.apache.daffodil.processors.TextTruncationType
 
 case class HexBinarySpecifiedLength(e: ElementBase) extends Terminal(e, true) {
 
@@ -192,6 +195,24 @@ case class HexBinaryEndOfBitLimit(e: ElementBase) extends Terminal(e, true) {
     e.elementRuntimeData)
 }
 
+case class HexBinaryLengthPrefixed(e: ElementBase) extends Terminal(e, true) {
+
+  override lazy val parser: DaffodilParser = new HexBinaryLengthPrefixedParser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.parser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+
+  override lazy val unparser: DaffodilUnparser = new HexBinaryLengthPrefixedUnparser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.unparser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.minLength.longValue,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+}
+
 abstract class PackedIntegerDelimited(e: ElementBase, signed: Boolean, packedSignCodes: PackedSignCodes)
   extends StringDelimited(e) {
 
@@ -333,6 +354,3 @@ case class LiteralNilDelimitedEndOfData(eb: ElementBase)
       isDelimRequired)
 
 }
-
-case class PrefixLength(e: ElementBase) extends UnimplementedPrimitive(e, e.lengthKind == LengthKind.Prefixed)
-
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesPacked.scala b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesPacked.scala
index 8ad930b..68d1643 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesPacked.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesPacked.scala
@@ -17,18 +17,23 @@
 
 package org.apache.daffodil.grammar.primitives
 
-import org.apache.daffodil.grammar.Terminal
 import org.apache.daffodil.dsom.ElementBase
-import org.apache.daffodil.util.PackedSignCodes
-import org.apache.daffodil.processors.parsers.PackedIntegerRuntimeLengthParser
-import org.apache.daffodil.processors.parsers.PackedIntegerKnownLengthParser
-import org.apache.daffodil.processors.parsers.PackedDecimalRuntimeLengthParser
+import org.apache.daffodil.grammar.Terminal
 import org.apache.daffodil.processors.parsers.PackedDecimalKnownLengthParser
-import org.apache.daffodil.processors.unparsers.Unparser
-import org.apache.daffodil.processors.unparsers.PackedIntegerRuntimeLengthUnparser
-import org.apache.daffodil.processors.unparsers.PackedIntegerKnownLengthUnparser
-import org.apache.daffodil.processors.unparsers.PackedDecimalRuntimeLengthUnparser
+import org.apache.daffodil.processors.parsers.PackedDecimalPrefixedLengthParser
+import org.apache.daffodil.processors.parsers.PackedDecimalRuntimeLengthParser
+import org.apache.daffodil.processors.parsers.PackedIntegerKnownLengthParser
+import org.apache.daffodil.processors.parsers.PackedIntegerPrefixedLengthParser
+import org.apache.daffodil.processors.parsers.PackedIntegerRuntimeLengthParser
 import org.apache.daffodil.processors.unparsers.PackedDecimalKnownLengthUnparser
+import org.apache.daffodil.processors.unparsers.PackedDecimalPrefixedLengthUnparser
+import org.apache.daffodil.processors.unparsers.PackedDecimalRuntimeLengthUnparser
+import org.apache.daffodil.processors.unparsers.PackedIntegerKnownLengthUnparser
+import org.apache.daffodil.processors.unparsers.PackedIntegerPrefixedLengthUnparser
+import org.apache.daffodil.processors.unparsers.PackedIntegerRuntimeLengthUnparser
+import org.apache.daffodil.processors.unparsers.Unparser
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.util.PackedSignCodes
 
 class PackedIntegerRuntimeLength(val e: ElementBase, signed: Boolean, packedSignCodes: PackedSignCodes) extends Terminal(e, true) {
   override lazy val parser = new PackedIntegerRuntimeLengthParser(e.elementRuntimeData, signed, packedSignCodes, e.lengthEv, e.lengthUnits)
@@ -43,6 +48,26 @@ class PackedIntegerKnownLength(val e: ElementBase, signed: Boolean, packedSignCo
   override lazy val unparser: Unparser = new PackedIntegerKnownLengthUnparser(e.elementRuntimeData, packedSignCodes, lengthInBits.toInt)
 }
 
+class PackedIntegerPrefixedLength(val e: ElementBase, signed: Boolean, packedSignCodes: PackedSignCodes) extends Terminal(e, true) {
+
+  override lazy val parser = new PackedIntegerPrefixedLengthParser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.parser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    signed,
+    packedSignCodes,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+
+  override lazy val unparser: Unparser = new PackedIntegerPrefixedLengthUnparser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.unparser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    packedSignCodes,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+}
+
 class PackedDecimalRuntimeLength(val e: ElementBase, packedSignCodes: PackedSignCodes) extends Terminal(e, true) {
   override lazy val parser = new PackedDecimalRuntimeLengthParser(e.elementRuntimeData, e.binaryDecimalVirtualPoint, packedSignCodes, e.lengthEv, e.lengthUnits)
 
@@ -55,3 +80,25 @@ class PackedDecimalKnownLength(val e: ElementBase, packedSignCodes: PackedSignCo
 
   override lazy val unparser: Unparser = new PackedDecimalKnownLengthUnparser(e.elementRuntimeData, e.binaryDecimalVirtualPoint, packedSignCodes, lengthInBits.toInt)
 }
+
+
+class PackedDecimalPrefixedLength(val e: ElementBase, packedSignCodes: PackedSignCodes) extends Terminal(e, true) {
+
+  override lazy val parser = new PackedDecimalPrefixedLengthParser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.parser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.binaryDecimalVirtualPoint,
+    packedSignCodes,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+
+  override lazy val unparser: Unparser = new PackedDecimalPrefixedLengthUnparser(
+    e.elementRuntimeData,
+    e.prefixedLengthBody.unparser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.binaryDecimalVirtualPoint,
+    packedSignCodes,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+}
diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/SpecifiedLength.scala b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/SpecifiedLength.scala
index 70061dc..c83ed70 100644
--- a/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/SpecifiedLength.scala
+++ b/daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/SpecifiedLength.scala
@@ -143,6 +143,30 @@ class SpecifiedLengthImplicit(e: ElementBase, eGram: => Gram, nBits: Long)
 
 }
 
+class SpecifiedLengthPrefixed(e: ElementBase, eGram: => Gram, bitsMultiplier: Int)
+  extends SpecifiedLengthCombinatorBase(e, eGram) {
+
+  Assert.usage(bitsMultiplier > 0)
+
+  lazy val kind = "Prefixed_" + e.lengthUnits.toString
+
+  lazy val parser: Parser = new SpecifiedLengthPrefixedParser(
+    eParser,
+    e.elementRuntimeData,
+    e.prefixedLengthBody.parser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+
+  lazy val unparser: Unparser = new SpecifiedLengthPrefixedUnparser(
+    eUnparser,
+    e.elementRuntimeData,
+    e.prefixedLengthBody.unparser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.lengthUnits,
+    e.prefixedLengthAdjustmentInUnits)
+}
+
 class SpecifiedLengthExplicitCharacters(e: ElementBase, eGram: => Gram)
   extends SpecifiedLengthCombinatorBase(e, eGram)
   with SpecifiedLengthExplicitImplicitUnparserMixin {
@@ -166,3 +190,18 @@ class SpecifiedLengthImplicitCharacters(e: ElementBase, eGram: => Gram, nChars:
     e.elementRuntimeData,
     nChars)
 }
+
+class SpecifiedLengthPrefixedCharacters(e: ElementBase, eGram: => Gram)
+  extends SpecifiedLengthCombinatorBase(e, eGram) {
+
+  val kind = "ExplicitCharacters"
+
+  lazy val parser: Parser = new SpecifiedLengthPrefixedCharactersParser(
+    eParser,
+    e.elementRuntimeData,
+    e.prefixedLengthBody.parser,
+    e.prefixedLengthElementDecl.elementRuntimeData,
+    e.prefixedLengthAdjustmentInUnits)
+
+  lazy val unparser: Unparser = Assert.nyi("unparsing with dfdl:lengthKind=\"prefixed\" and dfdl:lengthUnits=\"characters\"")
+}
diff --git a/daffodil-lib/src/main/scala/org/apache/daffodil/schema/annotation/props/Properties.scala b/daffodil-lib/src/main/scala/org/apache/daffodil/schema/annotation/props/Properties.scala
index 96d653e..69191d5 100644
--- a/daffodil-lib/src/main/scala/org/apache/daffodil/schema/annotation/props/Properties.scala
+++ b/daffodil-lib/src/main/scala/org/apache/daffodil/schema/annotation/props/Properties.scala
@@ -232,9 +232,8 @@ trait PropertyMixin
     pv
   }
 
-  def convertToQName(pv: String): String = {
-    // remember: schema validation already checked format of QName for us.
-    pv
+  def convertToQName(pv: String, pl: LookupLocation) = {
+    pl.resolveQName(pv)
   }
 
   def convertToNCName(pv: String): String = {
diff --git a/daffodil-lib/src/main/scala/org/apache/daffodil/util/DecimalUtils.scala b/daffodil-lib/src/main/scala/org/apache/daffodil/util/DecimalUtils.scala
index 9acbac6..f4b9060 100644
--- a/daffodil-lib/src/main/scala/org/apache/daffodil/util/DecimalUtils.scala
+++ b/daffodil-lib/src/main/scala/org/apache/daffodil/util/DecimalUtils.scala
@@ -115,17 +115,26 @@ object DecimalUtils {
     new JBigDecimal(packedToBigInteger(num, signCodes), scale)
   }
 
+  def packedFromBigIntegerLength(absBigIntAsString: String, minLengthInBits: Int): (Int, Int) = {
+    Assert.invariant(absBigIntAsString(0) != '-')
+    val numDigits = absBigIntAsString.length
+    val requiredBitLen = if (numDigits % 2 == 0) ((numDigits + 2) * 4) else ((numDigits + 1) * 4)
+    val bitLen = scala.math.max(minLengthInBits, requiredBitLen)
+    val numBytes = bitLen / 8
+    val leadingZeros = if (numDigits % 2 == 0) (bitLen/4 - numDigits - 1) else (bitLen/4 - numDigits)
+    (numBytes, leadingZeros)
+  }
+
   def packedFromBigInteger(bigInt: JBigInteger, minLengthInBits: Int, signCodes: PackedSignCodes): Array[Byte] = {
     val negative = (bigInt.signum != 1)
-    val inChars = bigInt.abs.toString.toCharArray
+    val inChars = bigInt.abs.toString
     val numDigits = inChars.length
-    // Length required to fit all the digits of the number including sign nibble
-    val requiredBitLen = if (numDigits % 2 == 0) ((numDigits + 2) * 4) else ((numDigits + 1) * 4)
-    val bitLen = scala.math.max(minLengthInBits, requiredBitLen)
+
+    val (numBytes, leadingZeros) = packedFromBigIntegerLength(inChars, minLengthInBits)
+    val outArray = new Array[Byte](numBytes)
+
     var offset = 0
     var inPos = 0
-    val outArray = new Array[Byte](bitLen/8)
-    val leadingZeros = if (numDigits % 2 == 0) (bitLen/4 - numDigits - 1) else (bitLen/4 - numDigits)
 
     // Add leading double zeros if necessary
     while ((offset * 2) < (leadingZeros - 1)) {
@@ -189,16 +198,25 @@ object DecimalUtils {
     new JBigDecimal(bcdToBigInteger(bcdNum), scale)
   }
 
-  def bcdFromBigInteger(bigInt: JBigInteger, minLengthInBits: Int): Array[Byte] = {
-    val inChars = bigInt.toString.toCharArray
-    val numDigits = inChars.length
+  def bcdFromBigIntegerLength(absBigIntAsString: String, minLengthInBits: Int): (Int, Int) = {
+    val numDigits = absBigIntAsString.length
     // Need to have an even number of digits to fill out a complete byte
     val requiredBitLen = if (numDigits % 2 == 0) (numDigits * 4) else ((numDigits + 1) * 4)
     val bitLen = scala.math.max(minLengthInBits, requiredBitLen)
+    val numBytes = (bitLen / 8)
+    val leadingZeros = bitLen/4 - numDigits
+    (numBytes, leadingZeros)
+  }
+
+  def bcdFromBigInteger(bigInt: JBigInteger, minLengthInBits: Int): Array[Byte] = {
+    val inChars = bigInt.toString
+    val numDigits = inChars.length
+    
+    val (numBytes, leadingZeros) = bcdFromBigIntegerLength(inChars, minLengthInBits)
+    val outArray = new Array[Byte](numBytes)
+
     var offset = 0
     var inPos = 0
-    val outArray = new Array[Byte](bitLen/8)
-    val leadingZeros = bitLen/4 - inChars.length
 
     // Add leading double zeros if necessary
     while ((offset * 2) < (leadingZeros - 1)) {
@@ -287,17 +305,27 @@ object DecimalUtils {
     new JBigDecimal(ibm4690ToBigInteger(num), scale)
   }
 
+  def ibm4690FromBigIntegerLength(absBigIntAsString: String, minLengthInBits: Int, negative: Boolean): (Int, Int) = {
+    Assert.invariant(absBigIntAsString(0) != '-')
+    val numDigits = if (negative) absBigIntAsString.length + 1 else absBigIntAsString.length
+    val requiredBitLen = if (numDigits % 2 == 0) (numDigits * 4) else ((numDigits + 1) * 4)
+    val bitLen = scala.math.max(minLengthInBits, requiredBitLen)
+    val numBytes = bitLen / 8
+    val leadingZeros = if (numDigits % 2 == 0) (bitLen/4 - numDigits) else (bitLen/4 - (numDigits + 1))
+    (numBytes, leadingZeros) 
+  }
+
   def ibm4690FromBigInteger(bigInt: JBigInteger, minLengthInBits: Int): Array[Byte] = {
     val negative = (bigInt.signum != 1)
-    val inChars = bigInt.abs.toString.toCharArray
+    val inChars = bigInt.abs.toString
+    val numDigits = if (negative) inChars.length + 1 else inChars.length
+
+    val (numBytes, leadingZeros) = ibm4690FromBigIntegerLength(inChars, minLengthInBits, negative)
+    val outArray = new Array[Byte](numBytes)
+
     var wrote_negative = false
     var offset = 0
     var inPos = 0
-    val numDigits = if (negative) inChars.length + 1 else inChars.length
-    val requiredBitLen = if (numDigits % 2 == 0) (numDigits * 4) else ((numDigits + 1) * 4)
-    val bitLen = scala.math.max(minLengthInBits, requiredBitLen)
-    val outArray = new Array[Byte](bitLen/8)
-    val leadingZeros = if (numDigits % 2 == 0) (bitLen/4 - numDigits) else (bitLen/4 - (numDigits + 1))
 
     // Add leading double zeros if necessary
     while ((offset * 2) < (leadingZeros - 1)) {
diff --git a/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala b/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
index fb7fb02..0811029 100644
--- a/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
+++ b/daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala
@@ -493,9 +493,18 @@ object Currency {
   }
 
   def generateNonEnumInstantiation(propName: String, typeName: String) = {
-    val midTemplate = """  def EUR = convertToTYPE(cacheProperty("EUR").value)
-"""
     val converterName = getConverterTypeName(typeName)
+    val midTemplate = if (converterName != "QName") {
+"""  def EUR = convertToTYPE(cacheProperty("EUR").value)
+"""
+    } else {
+"""  def EUR = {
+    val cp = cacheProperty("EUR")
+    convertToTYPE(cp.value, cp.location)
+  }
+"""
+    }
+
     val mid =
       if (excludeRuntimeProperties(propName)) ""
       else {
diff --git a/daffodil-propgen/src/test/scala/org/apache/daffodil/propGen/TestPropertyGenerator.scala b/daffodil-propgen/src/test/scala/org/apache/daffodil/propGen/TestPropertyGenerator.scala
index de52e1b..64dd9ef 100644
--- a/daffodil-propgen/src/test/scala/org/apache/daffodil/propGen/TestPropertyGenerator.scala
+++ b/daffodil-propgen/src/test/scala/org/apache/daffodil/propGen/TestPropertyGenerator.scala
@@ -128,7 +128,8 @@ class TestPropertyGenerator {
     val pg = new PropertyGenerator(sch)
     val mx = pg.genComplexType(sch)
     assertTrue(mx.contains("""convertToNCName(cacheProperty("name").value)"""))
-    assertTrue(mx.contains("""convertToQName(cacheProperty("baseFormat").value"""))
+    assertTrue(mx.contains("""cacheProperty("baseFormat")"""))
+    assertTrue(mx.contains("""convertToQName"""))
   }
 
   @Test def testElement1() {
diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BCDUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BCDUnparsers.scala
index 6766443..e97b8bc 100644
--- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BCDUnparsers.scala
+++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BCDUnparsers.scala
@@ -17,15 +17,20 @@
 
 package org.apache.daffodil.processors.unparsers
 
-import org.apache.daffodil.processors.parsers.HasKnownLengthInBits
-import org.apache.daffodil.processors.ElementRuntimeData
-import org.apache.daffodil.processors.ParseOrUnparseState
-import org.apache.daffodil.util.DecimalUtils
 import java.lang.{ Long => JLong }
 import java.math.{ BigInteger => JBigInteger }
-import org.apache.daffodil.processors.parsers.HasRuntimeExplicitLength
+
+import org.apache.daffodil.infoset.DISimple
+import org.apache.daffodil.infoset.Infoset
+import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.Processor
+import org.apache.daffodil.processors.parsers.HasKnownLengthInBits
+import org.apache.daffodil.processors.parsers.HasRuntimeExplicitLength
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.util.DecimalUtils
+import org.apache.daffodil.util.Maybe._
 
 abstract class BCDIntegerBaseUnparser(
   e: ElementRuntimeData)
@@ -44,7 +49,7 @@ class BCDIntegerKnownLengthUnparser(
 class BCDIntegerRuntimeLengthUnparser(
   val e: ElementRuntimeData,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends BCDIntegerBaseUnparser(e)
   with HasRuntimeExplicitLength {
 
@@ -58,6 +63,31 @@ final class BCDIntegerDelimitedUnparser(
   override def getBitLength(state: ParseOrUnparseState): Int = { 0 }
 }
 
+final class BCDIntegerPrefixedLengthUnparser(
+  e: ElementRuntimeData,
+  override val prefixedLengthUnparser: Unparser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends BCDIntegerBaseUnparser(e)
+  with KnownPrefixedLengthUnparserMixin {
+
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthUnparser)
+  override lazy val runtimeDependencies = Vector()
+
+  override def getBitLength(s: ParseOrUnparseState): Int = {
+    val number = getNumberToPut(s.asInstanceOf[UState])
+    val absBigIntStr = number.asInstanceOf[JBigInteger].abs.toString
+    val (byteLength, _) =  DecimalUtils.bcdFromBigIntegerLength(absBigIntStr, 0)
+    byteLength * 8
+  }
+
+  override def unparse(state: UState): Unit = {
+    unparsePrefixedLength(state)
+    super.unparse(state)
+  }
+}
+
 abstract class BCDDecimalBaseUnparser(
   e: ElementRuntimeData,
   binaryDecimalVirtualPoint: Int)
@@ -78,7 +108,7 @@ class BCDDecimalRuntimeLengthUnparser(
   val e: ElementRuntimeData,
   binaryDecimalVirtualPoint: Int,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends BCDDecimalBaseUnparser(e, binaryDecimalVirtualPoint)
   with HasRuntimeExplicitLength {
 
@@ -92,3 +122,29 @@ final class BCDDecimalDelimitedUnparser(
 
   override def getBitLength(state: ParseOrUnparseState): Int = { 0 }
 }
+
+final class BCDDecimalPrefixedLengthUnparser(
+  e: ElementRuntimeData,
+  override val prefixedLengthUnparser: Unparser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  binaryDecimalVirtualPoint: Int,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends BCDDecimalBaseUnparser(e, binaryDecimalVirtualPoint)
+  with KnownPrefixedLengthUnparserMixin {
+
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthUnparser)
+  override lazy val runtimeDependencies = Vector()
+
+  override def getBitLength(s: ParseOrUnparseState): Int = {
+    val number = getNumberToPut(s.asInstanceOf[UState])
+    val absBigIntStr = number.asInstanceOf[JBigInteger].abs.toString
+    val (byteLength, _) =  DecimalUtils.bcdFromBigIntegerLength(absBigIntStr, 0)
+    byteLength * 8
+  }
+
+  override def unparse(state: UState): Unit = {
+    unparsePrefixedLength(state)
+    super.unparse(state)
+  }
+}
diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BinaryBooleanUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BinaryBooleanUnparsers.scala
index 1f2d796..d053196 100644
--- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BinaryBooleanUnparsers.scala
+++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BinaryBooleanUnparsers.scala
@@ -17,50 +17,38 @@
 
 package org.apache.daffodil.processors.unparsers
 
-import org.apache.daffodil.processors.ElementRuntimeData
-import org.apache.daffodil.processors.ParseOrUnparseState
-import org.apache.daffodil.util.Maybe._
 import java.lang.{ Long => JLong, Boolean => JBoolean }
+
+import passera.unsigned.ULong
+
 import org.apache.daffodil.exceptions.Assert
-import org.apache.daffodil.processors.Evaluatable
-import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.infoset.DISimple
+import org.apache.daffodil.infoset.Infoset
 import org.apache.daffodil.io.DataOutputStream
+import org.apache.daffodil.io.FormatInfo
+import org.apache.daffodil.processors.ElementRuntimeData
+import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.Processor
 import org.apache.daffodil.schema.annotation.props.gen.LengthKind
-import org.apache.daffodil.util.Numbers
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.util.Maybe._
 import org.apache.daffodil.util.MaybeULong
-import passera.unsigned.ULong
-import org.apache.daffodil.io.FormatInfo
+import org.apache.daffodil.util.Numbers
 
-class BinaryBooleanUnparser(
-  e: ElementRuntimeData,
+abstract class BinaryBooleanUnparserBase(
+  override val context: ElementRuntimeData,
   binaryBooleanTrueRep: MaybeULong,
   binaryBooleanFalseRep: ULong,
-  val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits,
-  val lengthKind: LengthKind)
-  extends PrimUnparser() {
+  lengthUnits: LengthUnits)
+  extends PrimUnparser {
+
+  def getBitLength(s: ParseOrUnparseState): Int
 
-  lazy val toBits = lUnits match {
+  lazy val toBits = lengthUnits match {
     case LengthUnits.Bits => 1
     case LengthUnits.Bytes => 8
-    case _ => e.schemaDefinitionError("Binary Numbers must have length units of Bits or Bytes.")
-  }
-
-  def getBitLength(s: ParseOrUnparseState): Int = {
-    val nBytesAsJLong = lengthEv.evaluate(s)
-    val nBytes = Numbers.asInt(nBytesAsJLong)
-    lengthKind match {
-      case LengthKind.Implicit => nBytes
-      case _ => nBytes * toBits
-    }
-  }
-
-  override def context = e
-
-  override lazy val runtimeDependencies = Vector(lengthEv)
-
-  protected def putNumber(dos: DataOutputStream, value: ULong, nBits: Int, finfo: FormatInfo): Boolean = {
-    dos.putULong(value, nBits, finfo)
+    case _ => context.schemaDefinitionError("Binary Numbers must have length units of Bits or Bytes.")
   }
 
   def unparse(state: UState): Unit = {
@@ -87,8 +75,57 @@ class BinaryBooleanUnparser(
     if (!res) {
       Assert.invariant(dos.maybeRelBitLimit0b.isDefined)
       UnparseError(One(state.schemaFileLocation), One(state.currentLocation), "Insufficient space to unparse element %s, required %s bits, but only %s were available.",
-        e.dpathElementCompileInfo.namedQName.toPrettyString, nBits, dos.maybeRelBitLimit0b.get)
+        context.dpathElementCompileInfo.namedQName.toPrettyString, nBits, dos.maybeRelBitLimit0b.get)
     }
   }
 
+  protected def putNumber(dos: DataOutputStream, value: ULong, nBits: Int, finfo: FormatInfo): Boolean = {
+    dos.putULong(value, nBits, finfo)
+  }
+
+}
+
+class BinaryBooleanUnparser(
+  e: ElementRuntimeData,
+  binaryBooleanTrueRep: MaybeULong,
+  binaryBooleanFalseRep: ULong,
+  val lengthEv: Evaluatable[JLong],
+  val lengthUnits: LengthUnits,
+  val lengthKind: LengthKind)
+  extends BinaryBooleanUnparserBase(e, binaryBooleanTrueRep, binaryBooleanFalseRep, lengthUnits) {
+
+  override lazy val runtimeDependencies = Vector(lengthEv)
+
+  override def getBitLength(s: ParseOrUnparseState): Int = {
+    val nBytesAsJLong = lengthEv.evaluate(s)
+    val nBytes = Numbers.asInt(nBytesAsJLong)
+    lengthKind match {
+      case LengthKind.Implicit => nBytes
+      case _ => nBytes * toBits
+    }
+  }
+}
+
+class BinaryBooleanPrefixedLengthUnparser(
+  e: ElementRuntimeData,
+  override val prefixedLengthUnparser: Unparser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  binaryBooleanTrueRep: MaybeULong,
+  binaryBooleanFalseRep: ULong,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends BinaryBooleanUnparserBase(e, binaryBooleanTrueRep, binaryBooleanFalseRep, lengthUnits)
+  with KnownPrefixedLengthUnparserMixin {
+
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthUnparser)
+
+  override lazy val runtimeDependencies = Vector()
+
+  override def getBitLength(s: ParseOrUnparseState): Int = 32
+
+  override def unparse(state: UState): Unit = {
+    unparsePrefixedLength(state)
+    super.unparse(state)
+  }
+
 }
diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BinaryNumberUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BinaryNumberUnparsers.scala
index 8d4d423..10192b1 100644
--- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BinaryNumberUnparsers.scala
+++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/BinaryNumberUnparsers.scala
@@ -17,33 +17,42 @@
 
 package org.apache.daffodil.processors.unparsers
 
-import org.apache.daffodil.processors.parsers.HasKnownLengthInBits
-import org.apache.daffodil.processors.ElementRuntimeData
-import org.apache.daffodil.processors.ParseOrUnparseState
-import org.apache.daffodil.util.Maybe._
 import java.lang.{ Number => JNumber, Long => JLong }
+
 import org.apache.daffodil.exceptions.Assert
-import org.apache.daffodil.processors.parsers.HasRuntimeExplicitLength
+import org.apache.daffodil.infoset.DISimple
+import org.apache.daffodil.infoset.Infoset
+import org.apache.daffodil.io.DataOutputStream
+import org.apache.daffodil.io.FormatInfo
+import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.Processor
+import org.apache.daffodil.processors.parsers.HasKnownLengthInBits
+import org.apache.daffodil.processors.parsers.HasRuntimeExplicitLength
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
 import org.apache.daffodil.schema.annotation.props.gen.YesNo
-import org.apache.daffodil.io.DataOutputStream
+import org.apache.daffodil.util.Maybe._
+import org.apache.daffodil.util.MaybeInt
 import org.apache.daffodil.util.Numbers._
-import org.apache.daffodil.io.FormatInfo
+import org.apache.daffodil.util.Bits
 
 abstract class BinaryNumberBaseUnparser(override val context: ElementRuntimeData)
   extends PrimUnparser {
 
+  protected def getNumberToPut(state: UState): JNumber = {
+    val node = state.currentInfosetNode.asSimple
+    node.dataValue.asInstanceOf[JNumber]
+  }
+
   protected def getBitLength(s: ParseOrUnparseState): Int
 
   protected def putNumber(dos: DataOutputStream, number: JNumber, nBits: Int, finfo: FormatInfo): Boolean
 
   def unparse(state: UState): Unit = {
     val nBits = getBitLength(state)
-    val node = state.currentInfosetNode.asSimple
-    val value = node.dataValue.asInstanceOf[JNumber]
+    val value = getNumberToPut(state)
     val dos = state.dataOutputStream
-
     val res =
       if (nBits > 0) {
         putNumber(dos, value, nBits, state)
@@ -80,13 +89,47 @@ class BinaryIntegerKnownLengthUnparser(e: ElementRuntimeData, signed: Boolean, o
 
 }
 
-class BinaryIntegerRuntimeLengthUnparser(val e: ElementRuntimeData, signed: Boolean, val lengthEv: Evaluatable[JLong], val lUnits: LengthUnits)
+class BinaryIntegerRuntimeLengthUnparser(val e: ElementRuntimeData, signed: Boolean, val lengthEv: Evaluatable[JLong], val lengthUnits: LengthUnits)
   extends BinaryIntegerBaseUnparser(e, signed)
   with HasRuntimeExplicitLength {
 
   override val runtimeDependencies = Vector(lengthEv)
 }
 
+class BinaryIntegerPrefixedLengthUnparser(
+  e: ElementRuntimeData,
+  override val prefixedLengthUnparser: Unparser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  maybeNBits: MaybeInt,
+  signed: Boolean,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends BinaryIntegerBaseUnparser(e: ElementRuntimeData, signed: Boolean)
+  with KnownPrefixedLengthUnparserMixin {
+
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthUnparser)
+  override lazy val runtimeDependencies = Vector()
+
+  override def getBitLength(s: ParseOrUnparseState): Int = {
+    if (maybeNBits.isDefined) {
+      // not xs:integer, so is a fixed number of bits based on the prim type
+      maybeNBits.get
+    } else {
+      // type is xs:integer, the length is determined by the minimum number of
+      // bytes needed to represent the number
+      val value = getNumberToPut(s.asInstanceOf[UState])
+      val len = Math.max(asBigInt(value).bitLength, 1)
+      val signedLen = if (signed) len + 1 else len
+      (signedLen + 7) & ~0x7 // round up to nearest multilpe of 8
+    }
+  }
+
+  override def unparse(state: UState): Unit = {
+    unparsePrefixedLength(state)
+    super.unparse(state)
+  }
+}
+
 class BinaryFloatUnparser(e: ElementRuntimeData)
   extends BinaryNumberBaseUnparser(e) {
 
@@ -120,17 +163,48 @@ class BinaryDecimalKnownLengthUnparser(e: ElementRuntimeData, signed: YesNo, bin
 
 }
 
-class BinaryDecimalRuntimeLengthUnparser(val e: ElementRuntimeData, signed: YesNo, binaryDecimalVirtualPoint: Int, val lengthEv: Evaluatable[JLong], val lUnits: LengthUnits)
+class BinaryDecimalRuntimeLengthUnparser(val e: ElementRuntimeData, signed: YesNo, binaryDecimalVirtualPoint: Int, val lengthEv: Evaluatable[JLong], val lengthUnits: LengthUnits)
   extends BinaryDecimalUnparserBase(e, signed, binaryDecimalVirtualPoint)
   with HasRuntimeExplicitLength {
 
   override val runtimeDependencies = Vector(lengthEv)
 }
 
+class BinaryDecimalPrefixedLengthUnparser(
+  e: ElementRuntimeData,
+  override val prefixedLengthUnparser: Unparser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  signed: YesNo,
+  binaryDecimalVirtualPoint: Int,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends BinaryDecimalUnparserBase(e, signed, binaryDecimalVirtualPoint)
+  with KnownPrefixedLengthUnparserMixin {
+
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthUnparser)
+  override lazy val runtimeDependencies = Vector()
+
+  override def getBitLength(s: ParseOrUnparseState): Int = {
+    // type is xs:decimal, the length is determined by the minimum number of
+    // bytes needed to represent the number
+    val value = getNumberToPut(s.asInstanceOf[UState])
+    val len = Math.max(asBigInt(value).bitLength, 1)
+    val signedLen = if (signed == YesNo.Yes) len + 1 else len
+    (signedLen + 7) & ~0x7 // round up to nearest multilpe of 8
+  }
+
+  override def unparse(state: UState): Unit = {
+    unparsePrefixedLength(state)
+    super.unparse(state)
+  }
+}
+
 abstract class BinaryDecimalUnparserBase(e: ElementRuntimeData, signed: YesNo, binaryDecimalVirtualPoint: Int)
   extends BinaryNumberBaseUnparser(e) {
 
-  override def putNumber(dos: DataOutputStream, value: JNumber, nBits: Int, finfo: FormatInfo): Boolean = {
+  override def getNumberToPut(state: UState): JNumber = {
+    val node = state.currentInfosetNode.asSimple
+    val value = node.dataValue.asInstanceOf[JNumber]
 
     // We want to scale the bigInt by binaryDecimalVirtualPoint so that it is a BigInt
     val bigDec = asBigDecimal(value)
@@ -143,8 +217,10 @@ abstract class BinaryDecimalUnparserBase(e: ElementRuntimeData, signed: YesNo, b
     val bigInt =
       if (binaryDecimalVirtualPoint != 0) bigDec.scaleByPowerOfTen(binaryDecimalVirtualPoint).toBigInteger()
       else bigDec.toBigInteger()
+    bigInt
+  }
 
-    dos.putBigInt(bigInt, nBits, signed == YesNo.Yes, finfo)
-
+  override def putNumber(dos: DataOutputStream, value: JNumber, nBits: Int, finfo: FormatInfo): Boolean = {
+    dos.putBigInt(asBigInt(value), nBits, signed == YesNo.Yes, finfo)
   }
 }
diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/HexBinaryLengthUnparser.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/HexBinaryLengthUnparser.scala
index 4d24e81..cae4588 100644
--- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/HexBinaryLengthUnparser.scala
+++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/HexBinaryLengthUnparser.scala
@@ -17,11 +17,16 @@
 
 package org.apache.daffodil.processors.unparsers
 
-import org.apache.daffodil.processors.ElementRuntimeData
-import org.apache.daffodil.util.Maybe._
+import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.infoset.DISimple
+import org.apache.daffodil.infoset.Infoset
 import org.apache.daffodil.infoset.RetryableException
+import org.apache.daffodil.processors.ElementRuntimeData
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.Processor
 import org.apache.daffodil.processors.UnparseTargetLengthInBitsEv
-import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.util.Maybe._
 
 abstract class HexBinaryUnparserBase(override val context: ElementRuntimeData)
   extends PrimUnparser {
@@ -30,7 +35,7 @@ abstract class HexBinaryUnparserBase(override val context: ElementRuntimeData)
 
   protected def getLengthInBits(state: UState): Long
 
-  override final def unparse(state: UState): Unit = {
+  override def unparse(state: UState): Unit = {
 
     val node = state.currentInfosetNode.asSimple
     val value = node.dataValue.asInstanceOf[Array[Byte]]
@@ -74,7 +79,7 @@ abstract class HexBinaryUnparserBase(override val context: ElementRuntimeData)
   }
 }
 
-final class HexBinaryMinLengthInBytesUnparser(minLengthInBytes: Long, erd: ElementRuntimeData)
+class HexBinaryMinLengthInBytesUnparser(minLengthInBytes: Long, erd: ElementRuntimeData)
   extends HexBinaryUnparserBase(erd) {
 
   override def getLengthInBits(state: UState): Long = {
@@ -100,3 +105,26 @@ final class HexBinarySpecifiedLengthUnparser(erd: ElementRuntimeData, val length
     l
   }
 }
+
+final class HexBinaryLengthPrefixedUnparser(
+  erd: ElementRuntimeData,
+  override val prefixedLengthUnparser: Unparser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  minLengthInBytes: Long,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends HexBinaryMinLengthInBytesUnparser(minLengthInBytes, erd)
+  with KnownPrefixedLengthUnparserMixin {
+
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthUnparser)
+
+  override def getBitLength(state: ParseOrUnparseState): Int = {
+    val bits = getLengthInBits(state.asInstanceOf[UState])
+    bits.toInt
+  }
+
+  override def unparse(state: UState): Unit = {
+    unparsePrefixedLength(state)
+    super.unparse(state)
+  }
+}
diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/IBM4690PackedDecimalUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/IBM4690PackedDecimalUnparsers.scala
index 918b5c2..f9bebe2 100644
--- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/IBM4690PackedDecimalUnparsers.scala
+++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/IBM4690PackedDecimalUnparsers.scala
@@ -17,15 +17,20 @@
 
 package org.apache.daffodil.processors.unparsers
 
-import org.apache.daffodil.processors.parsers.HasKnownLengthInBits
-import org.apache.daffodil.processors.ElementRuntimeData
-import org.apache.daffodil.processors.ParseOrUnparseState
-import org.apache.daffodil.util.DecimalUtils
 import java.lang.{ Long => JLong }
 import java.math.{ BigInteger => JBigInteger }
-import org.apache.daffodil.processors.parsers.HasRuntimeExplicitLength
+
+import org.apache.daffodil.infoset.Infoset
+import org.apache.daffodil.infoset.DISimple
+import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.Processor
+import org.apache.daffodil.processors.parsers.HasKnownLengthInBits
+import org.apache.daffodil.processors.parsers.HasRuntimeExplicitLength
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.util.DecimalUtils
+import org.apache.daffodil.util.Maybe._
 
 abstract class IBM4690PackedIntegerBaseUnparser(
   e: ElementRuntimeData)
@@ -44,7 +49,7 @@ class IBM4690PackedIntegerKnownLengthUnparser(
 class IBM4690PackedIntegerRuntimeLengthUnparser(
   val e: ElementRuntimeData,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends IBM4690PackedIntegerBaseUnparser(e)
   with HasRuntimeExplicitLength {
 
@@ -58,6 +63,33 @@ final class IBM4690PackedIntegerDelimitedUnparser(
   override def getBitLength(state: ParseOrUnparseState): Int = { 0 }
 }
 
+final class IBM4690PackedIntegerPrefixedLengthUnparser(
+  e: ElementRuntimeData,
+  override val prefixedLengthUnparser: Unparser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends IBM4690PackedIntegerBaseUnparser(e)
+  with KnownPrefixedLengthUnparserMixin {
+
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthUnparser)
+  override lazy val runtimeDependencies = Vector()
+
+  override def getBitLength(s: ParseOrUnparseState): Int = {
+    val number = getNumberToPut(s.asInstanceOf[UState])
+    val bigInt = number.asInstanceOf[JBigInteger]
+    val absBigIntStr = bigInt.abs.toString
+    val negative = (bigInt.signum != 1)
+    val (byteLength, _) =  DecimalUtils.ibm4690FromBigIntegerLength(absBigIntStr, 0, negative)
+    byteLength * 8
+  }
+
+  override def unparse(state: UState): Unit = {
+    unparsePrefixedLength(state)
+    super.unparse(state)
+  }
+}
+
 abstract class IBM4690PackedDecimalBaseUnparser(
   e: ElementRuntimeData,
   binaryDecimalVirtualPoint: Int)
@@ -78,7 +110,7 @@ class IBM4690PackedDecimalRuntimeLengthUnparser(
   val e: ElementRuntimeData,
   binaryDecimalVirtualPoint: Int,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends IBM4690PackedDecimalBaseUnparser(e, binaryDecimalVirtualPoint)
   with HasRuntimeExplicitLength {
 
@@ -92,3 +124,31 @@ final class IBM4690PackedDecimalDelimitedUnparser(
 
   override def getBitLength(state: ParseOrUnparseState): Int = { 0 }
 }
+
+final class IBM4690PackedDecimalPrefixedLengthUnparser(
+  e: ElementRuntimeData,
+  override val prefixedLengthUnparser: Unparser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  binaryDecimalVirtualPoint: Int,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends IBM4690PackedDecimalBaseUnparser(e, binaryDecimalVirtualPoint)
+  with KnownPrefixedLengthUnparserMixin {
+  
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthUnparser)
+  override lazy val runtimeDependencies = Vector()
+
+  override def getBitLength(s: ParseOrUnparseState): Int = {
+    val number = getNumberToPut(s.asInstanceOf[UState])
+    val bigInt = number.asInstanceOf[JBigInteger]
+    val absBigIntStr = bigInt.abs.toString
+    val negative = (bigInt.signum != 1)
+    val (byteLength, _) =  DecimalUtils.ibm4690FromBigIntegerLength(absBigIntStr, 0, negative)
+    byteLength * 8
+  }
+
+  override def unparse(state: UState): Unit = {
+    unparsePrefixedLength(state)
+    super.unparse(state)
+  }
+}
diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/NilUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/NilUnparsers.scala
index aa9ea21..473cd4d 100644
--- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/NilUnparsers.scala
+++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/NilUnparsers.scala
@@ -28,7 +28,9 @@ class LiteralValueNilOfSpecifiedLengthUnparser(
 
   override lazy val runtimeDependencies = Vector(slEv)
 
-  override protected def contentString(state: UState) = slEv.evaluate(state)
+  override protected def contentString(state: UState) = {
+    slEv.evaluate(state)
+  }
 
 }
 
diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/PackedBinaryUnparserTraits.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/PackedBinaryUnparserTraits.scala
index 2185ef9..39200c5 100644
--- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/PackedBinaryUnparserTraits.scala
+++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/PackedBinaryUnparserTraits.scala
@@ -17,16 +17,21 @@
 
 package org.apache.daffodil.processors.unparsers
 
-import org.apache.daffodil.processors.ElementRuntimeData
-import org.apache.daffodil.processors.ParseOrUnparseState
-import org.apache.daffodil.util.Maybe._
 import java.lang.{ Number => JNumber }
 import java.math.{ BigInteger => JBigInteger, BigDecimal => JBigDecimal }
+
+import org.apache.daffodil.dpath.NodeInfo
 import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.infoset.Infoset
+import org.apache.daffodil.infoset.DISimple
 import org.apache.daffodil.io.DataOutputStream
 import org.apache.daffodil.io.FormatInfo
+import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.Evaluatable
-import org.apache.daffodil.dpath.NodeInfo
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.Processor
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.util.Maybe._
 
 trait PackedBinaryConversion {
   def fromBigInteger(bigInt: JBigInteger, nBits: Int): Array[Byte]
@@ -42,9 +47,8 @@ abstract class PackedBinaryBaseUnparser(
   protected def getBitLength(s: ParseOrUnparseState): Int
 
   def putNumber(dos: DataOutputStream, number: JNumber, nBits: Int, finfo: FormatInfo): Boolean
-
-  override def unparse(state: UState): Unit = {
-    val nBits = getBitLength(state)
+  
+  def getNumberToPut(state: UState): JNumber = {
     val node = state.currentInfosetNode.asSimple
 
     // Packed decimal calendars use the convert combinator which sets the string value of the calendar
@@ -58,8 +62,13 @@ abstract class PackedBinaryBaseUnparser(
     }
 
     val value = nodeValue.asInstanceOf[JNumber]
-    val dos = state.dataOutputStream
+    value
+  }
 
+  override def unparse(state: UState): Unit = {
+    val nBits = getBitLength(state)
+    val value = getNumberToPut(state)
+    val dos = state.dataOutputStream
     val res = putNumber(dos, value, nBits, state)
 
     if (!res) {
@@ -76,29 +85,36 @@ abstract class PackedBinaryDecimalBaseUnparser(
   binaryDecimalVirtualPoint: Int)
   extends PackedBinaryBaseUnparser(e) {
 
-  override def putNumber(dos: DataOutputStream, number: JNumber, nBits: Int, finfo: FormatInfo): Boolean = {
-
+  override def getNumberToPut(ustate: UState): JNumber = {
+    val number = super.getNumberToPut(ustate)
     val bigDec = number.asInstanceOf[JBigDecimal]
-    if (bigDec.movePointRight(binaryDecimalVirtualPoint).scale != 0)
+    if (bigDec.movePointRight(binaryDecimalVirtualPoint).scale != 0) {
       e.schemaDefinitionError("Decimal point of number '%s' does not match the binaryVirtualDecmialPoint: %d", bigDec, binaryDecimalVirtualPoint)
-
-      val packedNum = fromBigInteger(bigDec.unscaledValue, nBits)
-      dos.putByteArray(packedNum, packedNum.length * 8, finfo)
     }
+    bigDec.unscaledValue
+  }
+
+  override def putNumber(dos: DataOutputStream, number: JNumber, nBits: Int, finfo: FormatInfo): Boolean = {
+    val packedNum = fromBigInteger(number.asInstanceOf[JBigInteger], nBits)
+    dos.putByteArray(packedNum, packedNum.length * 8, finfo)
+  }
 }
 
 abstract class PackedBinaryIntegerBaseUnparser(
   e: ElementRuntimeData)
   extends PackedBinaryBaseUnparser(e) {
 
-  override def putNumber(dos: DataOutputStream, number: JNumber, nBits: Int, finfo: FormatInfo): Boolean = {
-
-      val bigInt = number.isInstanceOf[JBigInteger] match {
-        case true => number.asInstanceOf[JBigInteger]
-        case false => new JBigInteger(number.toString)
-      }
+  override def getNumberToPut(ustate: UState): JNumber = { 
+    val number = super.getNumberToPut(ustate)
+    val bigInt = number.isInstanceOf[JBigInteger] match {
+      case true => number.asInstanceOf[JBigInteger]
+      case false => new JBigInteger(number.toString)
+    }
+    bigInt
+  }
 
-      val packedNum = fromBigInteger(bigInt, nBits)
-      dos.putByteArray(packedNum, packedNum.length * 8, finfo)
+  override def putNumber(dos: DataOutputStream, number: JNumber, nBits: Int, finfo: FormatInfo): Boolean = {
+    val packedNum = fromBigInteger(number.asInstanceOf[JBigInteger], nBits)
+    dos.putByteArray(packedNum, packedNum.length * 8, finfo)
   }
 }
diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/PackedDecimalUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/PackedDecimalUnparsers.scala
index 7e3d225..836dbe1 100644
--- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/PackedDecimalUnparsers.scala
+++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/PackedDecimalUnparsers.scala
@@ -17,15 +17,18 @@
 
 package org.apache.daffodil.processors.unparsers
 
-import org.apache.daffodil.processors.parsers.HasKnownLengthInBits
-import org.apache.daffodil.processors.ElementRuntimeData
-import org.apache.daffodil.processors.ParseOrUnparseState
-import org.apache.daffodil.util.{ DecimalUtils, PackedSignCodes }
 import java.lang.{ Long => JLong }
 import java.math.{ BigInteger => JBigInteger }
-import org.apache.daffodil.processors.parsers.HasRuntimeExplicitLength
+
+import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.parsers.HasKnownLengthInBits
+import org.apache.daffodil.processors.parsers.HasRuntimeExplicitLength
+import org.apache.daffodil.processors.Processor
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.util.{ DecimalUtils, PackedSignCodes }
+
 
 abstract class PackedIntegerBaseUnparser(
   e: ElementRuntimeData,
@@ -47,7 +50,7 @@ class PackedIntegerRuntimeLengthUnparser(
   val e: ElementRuntimeData,
   packedSignCodes: PackedSignCodes,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends PackedIntegerBaseUnparser(e, packedSignCodes)
   with HasRuntimeExplicitLength {
 
@@ -62,6 +65,32 @@ final class PackedIntegerDelimitedUnparser(
   override def getBitLength(state: ParseOrUnparseState): Int = { 0 }
 }
 
+final class PackedIntegerPrefixedLengthUnparser(
+  e: ElementRuntimeData,
+  override val prefixedLengthUnparser: Unparser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  packedSignCodes: PackedSignCodes,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends PackedIntegerBaseUnparser(e, packedSignCodes)
+  with KnownPrefixedLengthUnparserMixin {
+
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthUnparser)
+  override lazy val runtimeDependencies = Vector()
+
+  override def getBitLength(s: ParseOrUnparseState): Int = {
+    val number = getNumberToPut(s.asInstanceOf[UState])
+    val absBigIntStr = number.asInstanceOf[JBigInteger].abs.toString
+    val (byteLength, _) = DecimalUtils.packedFromBigIntegerLength(absBigIntStr, 0)
+    byteLength * 8
+  }
+
+  override def unparse(state: UState): Unit = {
+    unparsePrefixedLength(state)
+    super.unparse(state)
+  }
+}
+
 
 abstract class PackedDecimalBaseUnparser(
   e: ElementRuntimeData,
@@ -86,7 +115,7 @@ class PackedDecimalRuntimeLengthUnparser(
   binaryDecimalVirtualPoint: Int,
   packedSignCodes: PackedSignCodes,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends PackedDecimalBaseUnparser(e, binaryDecimalVirtualPoint, packedSignCodes)
   with HasRuntimeExplicitLength {
 
@@ -101,3 +130,31 @@ final class PackedDecimalDelimitedUnparser(
 
   override def getBitLength(state: ParseOrUnparseState): Int = { 0 }
 }
+
+final class PackedDecimalPrefixedLengthUnparser(
+  e: ElementRuntimeData,
+  override val prefixedLengthUnparser: Unparser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  binaryDecimalVirtualPoint: Int,
+  packedSignCodes: PackedSignCodes,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends PackedDecimalBaseUnparser(e, binaryDecimalVirtualPoint, packedSignCodes)
+  with KnownPrefixedLengthUnparserMixin {
+  
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthUnparser)
+  override lazy val runtimeDependencies = Vector()
+
+  override def getBitLength(s: ParseOrUnparseState): Int = {
+    val number = getNumberToPut(s.asInstanceOf[UState])
+    val absBigIntStr = number.asInstanceOf[JBigInteger].abs.toString
+    val (byteLength, _) = DecimalUtils.packedFromBigIntegerLength(absBigIntStr, 0)
+    byteLength * 8
+  }
+
+  override def unparse(state: UState): Unit = {
+    unparsePrefixedLength(state)
+    super.unparse(state)
+  }
+
+}
diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/SpecifiedLength2.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/SpecifiedLength2.scala
index c43b1e3..db20809 100644
--- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/SpecifiedLength2.scala
+++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/SpecifiedLength2.scala
@@ -25,6 +25,7 @@ import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.SuspendableOperation
 import org.apache.daffodil.processors.UnparseTargetLengthInBitsEv
 import org.apache.daffodil.processors.charset.BitsCharset
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
 import org.apache.daffodil.util.LogLevel
 import org.apache.daffodil.util.Maybe
 import org.apache.daffodil.util.Maybe._
@@ -164,14 +165,14 @@ import java.nio.charset.UnmappableCharacterException
  * the number of bits to characters.
  */
 
-class OVCRetryUnparserSuspendableOperation(
+class SimpleTypeRetryUnparserSuspendableOperation(
   override val rd: ElementRuntimeData,
   maybeUnparserTargetLengthInBitsEv: Maybe[UnparseTargetLengthInBitsEv], vUnparser: Unparser)
   extends SuspendableOperation {
 
   override protected def maybeKnownLengthInBits(ustate: UState): MaybeULong = {
     // Note that we cannot use a targetLengthInBitsEv to determine the
-    // knownLengthInBits. This is because even if an OVC element has fixed
+    // knownLengthInBits. This is because even if an OVC/Simple element has fixed
     // length, the result of the OVC might not actually write that many bits,
     // relying on padding and/or right fill to fill in the remaining bits
     //
@@ -195,7 +196,7 @@ class OVCRetryUnparserSuspendableOperation(
   }
 }
 
-class OVCRetryUnparser(
+class SimpleTypeRetryUnparser(
   override val context: ElementRuntimeData,
   maybeUnparserTargetLengthInBitsEv: Maybe[UnparseTargetLengthInBitsEv], vUnparser: Unparser)
   extends PrimUnparser
@@ -205,7 +206,7 @@ class OVCRetryUnparser(
 
   final override lazy val childProcessors = Vector(vUnparser)
 
-  def suspendableOperation = new OVCRetryUnparserSuspendableOperation(
+  def suspendableOperation = new SimpleTypeRetryUnparserSuspendableOperation(
     context, maybeUnparserTargetLengthInBitsEv, vUnparser)
 
 }
@@ -698,3 +699,32 @@ class RightFillUnparser(
 
 }
 
+
+class PrefixLengthSuspendableOperation(
+  override val rd: ElementRuntimeData,
+  elem: DIElement,
+  plElem: DISimple,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends SuspendableOperation
+  with CalculatedPrefixedLengthUnparserMixin {
+
+  override val isReadOnly = true
+
+  override def toString = "prefix length for " + rd.diagnosticDebugName
+
+  /**
+   * This override indicates that this operation itself doesn't correspond
+   * to any bits in the unparsed data stream. It's just a computation.
+   */
+  override protected def maybeKnownLengthInBits(ustate: UState): MaybeULong = MaybeULong(0L)
+
+  override def test(ustate: UState): Boolean = {
+    elem.valueLength.maybeLengthInBits.isDefined
+  }
+
+  override def continuation(state: UState) {
+    val len = elem.valueLength.maybeLengthInBits.isDefined
+    assignPrefixLength(elem, plElem)
+  }
+}
diff --git a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/SpecifiedLengthUnparsers.scala b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/SpecifiedLengthUnparsers.scala
index fb4c03f..3a790f3 100644
--- a/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/SpecifiedLengthUnparsers.scala
+++ b/daffodil-runtime1-unparser/src/main/scala/org/apache/daffodil/processors/unparsers/SpecifiedLengthUnparsers.scala
@@ -17,20 +17,27 @@
 
 package org.apache.daffodil.processors.unparsers
 
-//import org.apache.daffodil.exceptions.Assert
+import passera.unsigned.ULong
+
+import org.apache.daffodil.dpath.NodeInfo.PrimType
+import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.infoset.DIElement
+import org.apache.daffodil.infoset.DISimple
+import org.apache.daffodil.infoset.Infoset
+import org.apache.daffodil.infoset.RetryableException
+import org.apache.daffodil.io.DataOutputStream
+import org.apache.daffodil.processors.CharsetEv
 import org.apache.daffodil.processors.ElementRuntimeData
+import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.ParseOrUnparseState
 import org.apache.daffodil.processors.Success
 import org.apache.daffodil.processors.UnparseTargetLengthInBitsEv
-import org.apache.daffodil.processors.CharsetEv
+import org.apache.daffodil.processors.UnparseTargetLengthInCharactersEv
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
-import org.apache.daffodil.exceptions.Assert
 import org.apache.daffodil.schema.annotation.props.gen.Representation
-import org.apache.daffodil.util.MaybeJULong
 import org.apache.daffodil.util.Maybe
-import org.apache.daffodil.processors.UnparseTargetLengthInCharactersEv
-import org.apache.daffodil.processors.Evaluatable
-import org.apache.daffodil.dpath.NodeInfo.PrimType
-import org.apache.daffodil.infoset.RetryableException
+import org.apache.daffodil.util.Maybe._
+import org.apache.daffodil.util.MaybeJULong
 
 /**
  * Restricts the bits available for unparsing to just those within
@@ -276,3 +283,148 @@ final class SpecifiedLengthExplicitImplicitUnparser(
     }
   }
 }
+
+// TODO: implement the capture length unparsers as just using this trait?
+trait CaptureUnparsingValueLength {
+
+  def captureValueLengthStart(state: UState, elem: DIElement) {
+    val dos = state.dataOutputStream
+    if (dos.maybeAbsBitPos0b.isDefined) {
+      elem.valueLength.setAbsStartPos0bInBits(dos.maybeAbsBitPos0b.getULong)
+    } else {
+      elem.valueLength.setRelStartPos0bInBits(dos.relBitPos0b, dos)
+    }
+  }
+
+  def captureValueLengthEnd(state: UState, elem: DIElement) {
+    val dos = state.dataOutputStream
+    if (dos.maybeAbsBitPos0b.isDefined) {
+      elem.valueLength.setAbsEndPos0bInBits(dos.maybeAbsBitPos0b.getULong)
+    } else {
+      elem.valueLength.setRelEndPos0bInBits(dos.relBitPos0b, dos)
+    }
+  }
+}
+
+/**
+ * This trait is to be used with prefixed length unparsers where the length is
+ * known without needing to unparse the data. This means there is either a
+ * fixed length (like in the case of some binary numbers), or the length can be
+ * determined completly be inspecting the infoset data (like in the case of
+ * packed decimals). The length calculation performed in the getBitLength
+ * function, which returns the length of the data in bits.
+ */
+trait KnownPrefixedLengthUnparserMixin {
+  def prefixedLengthERD: ElementRuntimeData
+  def prefixedLengthUnparser: Unparser
+  def lengthUnits: LengthUnits
+  def getBitLength(s: ParseOrUnparseState): Int
+  def prefixedLengthAdjustmentInUnits: Long
+
+  def unparsePrefixedLength(state: UState): Unit = {
+    val bits = getBitLength(state)
+    val lenInUnits =
+      if (lengthUnits == LengthUnits.Bytes) {
+        bits >> 3
+      } else {
+        bits
+      }
+    val adjustedLenInUnits = lenInUnits + prefixedLengthAdjustmentInUnits
+
+    // create a "detached" element that the prefix length will be parsed to.
+    val plElement = Infoset.newElement(prefixedLengthERD, state.tunable).asInstanceOf[DISimple]
+    plElement.setDataValue(java.lang.Integer.valueOf(adjustedLenInUnits.toInt))
+
+    // unparse the prefixed length element
+    state.currentInfosetNodeStack.push(One(plElement))
+    prefixedLengthUnparser.unparse1(state)
+    state.currentInfosetNodeStack.pop
+  }
+}
+
+/**
+ * This trait is to be used with prefixed length unparsers where the length
+ * must be calculated based on the value length of the data. This means the
+ * data must be unparsed, the value length calculated, and that value will be
+ * assigned to the prefix length element.
+ */
+trait CalculatedPrefixedLengthUnparserMixin {
+  def lengthUnits: LengthUnits
+  def prefixedLengthAdjustmentInUnits: Long
+
+  /**
+   * Gets the length of a provided element and stores the unit adjusted length
+   * as the value in the element that represent its prefix length
+   *
+   * @param elem The element who's length to get
+   * @param plElem The element to store the length
+   * @param lengthUnits The length units (bytes or bits)
+   */
+  def assignPrefixLength(elem: DIElement, plElem: DISimple): Unit = {
+    val lenInUnits = lengthUnits match {
+      case LengthUnits.Bits => elem.valueLength.lengthInBits
+      case LengthUnits.Bytes => elem.valueLength.lengthInBytes
+      case LengthUnits.Characters => ???
+    }
+    val adjustedLenInUnits = lenInUnits + prefixedLengthAdjustmentInUnits
+    plElem.setDataValue(java.lang.Integer.valueOf(adjustedLenInUnits.toInt))
+  }
+}
+
+class SpecifiedLengthPrefixedUnparser(
+  eUnparser: Unparser,
+  erd: ElementRuntimeData,
+  prefixedLengthUnparser: Unparser,
+  prefixedLengthERD: ElementRuntimeData,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends CombinatorUnparser(erd)
+  with CaptureUnparsingValueLength
+  with CalculatedPrefixedLengthUnparserMixin {
+
+  override lazy val runtimeDependencies = Vector()
+
+  override lazy val childProcessors = Vector(prefixedLengthUnparser, eUnparser)
+
+  override def unparse(state: UState): Unit = {
+    // create a "detached" element that the prefix length will be used to unparse
+    val plElem = Infoset.newElement(prefixedLengthERD, state.tunable).asInstanceOf[DISimple]
+
+    // The prefixedLengthUnparser is going to end up creating a suspension
+    // because plElem does not have a value yet. We will temporary push the
+    // detached element to the stack, the suspension will clone the ustate and
+    // keep track of that detached element, then we can pop it off the stack as
+    // it's no longer needed.
+    state.currentInfosetNodeStack.push(One(plElem))
+    prefixedLengthUnparser.unparse1(state)
+    state.currentInfosetNodeStack.pop
+
+    // We now need to capture the length of the actual element
+    val elem = state.currentInfosetNode.asInstanceOf[DIElement]
+    captureValueLengthStart(state, elem)
+    eUnparser.unparse1(state)
+    captureValueLengthEnd(state, elem)
+
+    if (elem.valueLength.maybeLengthInBits.isDefined) {
+      // If we were able to immediately calculate the length of the element,
+      // then just set it as the value of the detached element created above so
+      // that when the prefixedLengthUnparser suspension resumes it can unparse
+      // the value
+      assignPrefixLength(elem, plElem)
+    } else {
+      // The length was not able to be calculated, likely because there was a
+      // suspension when unparsing the eUnparser. So let's create a new
+      // suspension with the only goal to retry until the valueLength of this
+      // element is determined. Once determined, it will set the value of the
+      // prefix length element, ultimately allowing the prefix length element
+      // suspension to resume and unparse the value
+      val suspension = new PrefixLengthSuspendableOperation(erd, elem, plElem, lengthUnits, prefixedLengthAdjustmentInUnits)
+
+      // Run the suspension--we know he suspension will not be able to succeed
+      // since maybeLengthInBits is not defined, but this performs various
+      // actions to suspend the operation and allow it to be run later
+      suspension.run(state)
+    }
+  }
+
+}
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/BCDParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/BCDParsers.scala
index c259d8f..a3acd39 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/BCDParsers.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/BCDParsers.scala
@@ -17,12 +17,15 @@
 
 package org.apache.daffodil.processors.parsers
 
+import java.lang.{ Long => JLong }
+import java.math.{ BigInteger => JBigInteger, BigDecimal => JBigDecimal }
+
+import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.Processor
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
-import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.util.DecimalUtils
-import java.lang.{ Long => JLong }
-import java.math.{ BigInteger => JBigInteger, BigDecimal => JBigDecimal }
 
 class BCDDecimalKnownLengthParser(
   e: ElementRuntimeData,
@@ -40,7 +43,7 @@ class BCDDecimalRuntimeLengthParser(
   val e: ElementRuntimeData,
   binaryDecimalVirtualPoint: Int,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends PackedBinaryDecimalBaseParser(e, binaryDecimalVirtualPoint)
   with HasRuntimeExplicitLength {
 
@@ -49,10 +52,31 @@ class BCDDecimalRuntimeLengthParser(
 
 }
 
+class BCDDecimalPrefixedLengthParser(
+  e: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  binaryDecimalVirtualPoint: Int,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends PackedBinaryDecimalBaseParser(e, binaryDecimalVirtualPoint)
+  with PrefixedLengthParserMixin {
+
+  override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.bcdToBigInteger(num)
+  override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = DecimalUtils.bcdToBigDecimal(num, scale)
+  
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthParser)
+      
+  override def getBitLength(state: ParseOrUnparseState): Int = {
+    getPrefixedLengthInBits(state.asInstanceOf[PState]).toInt
+  }
+
+}
+
 class BCDIntegerRuntimeLengthParser(
   val e: ElementRuntimeData,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends PackedBinaryIntegerBaseParser(e)
   with HasRuntimeExplicitLength {
 
@@ -71,3 +95,23 @@ class BCDIntegerKnownLengthParser(
   override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = DecimalUtils.bcdToBigDecimal(num, scale)
 
 }
+
+class BCDIntegerPrefixedLengthParser(
+  e: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends PackedBinaryIntegerBaseParser(e)
+  with PrefixedLengthParserMixin {
+
+  override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.bcdToBigInteger(num)
+  override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = DecimalUtils.bcdToBigDecimal(num, scale)
+  
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthParser)
+      
+  override def getBitLength(state: ParseOrUnparseState): Int = {
+    getPrefixedLengthInBits(state.asInstanceOf[PState]).toInt
+  }
+}
+
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/EvElement.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/EvElement.scala
index fac552a..b7e08ed 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/EvElement.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/EvElement.scala
@@ -17,17 +17,27 @@
 
 package org.apache.daffodil.processors
 
-import org.apache.daffodil.dsom._
 import java.lang.{ Long => JLong }
-import org.apache.daffodil.util.MaybeJULong
-import org.apache.daffodil.util.Maybe
-import org.apache.daffodil.dpath.UnparserBlocking
+
+import org.apache.daffodil.cookers.ChoiceDispatchKeyCooker
+import org.apache.daffodil.cookers.OutputNewLineCooker
 import org.apache.daffodil.dpath.EvalMode
-import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.dpath.ExpressionEvaluationException
+import org.apache.daffodil.dpath.NodeInfo.PrimType
+import org.apache.daffodil.dpath.UnparserBlocking
+import org.apache.daffodil.dsom._
 import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.infoset.DISimple
+import org.apache.daffodil.infoset.Infoset
+import org.apache.daffodil.processors.parsers.Parser
+import org.apache.daffodil.processors.parsers.PState
+import org.apache.daffodil.processors.unparsers.Unparser
+import org.apache.daffodil.processors.unparsers.UState
 import org.apache.daffodil.schema.annotation.props.gen.LengthKind
-import org.apache.daffodil.cookers.OutputNewLineCooker
-import org.apache.daffodil.cookers.ChoiceDispatchKeyCooker
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.util.Maybe
+import org.apache.daffodil.util.MaybeJULong
+import org.apache.daffodil.util.Numbers
 
 sealed trait LengthEv extends Evaluatable[JLong]
 
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/IBM4690PackedDecimalParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/IBM4690PackedDecimalParsers.scala
index 33949d0..83c22b3 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/IBM4690PackedDecimalParsers.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/IBM4690PackedDecimalParsers.scala
@@ -17,12 +17,15 @@
 
 package org.apache.daffodil.processors.parsers
 
+import java.lang.{ Long => JLong }
+import java.math.{ BigInteger => JBigInteger, BigDecimal => JBigDecimal }
+
+import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.Processor
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
-import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.util.DecimalUtils
-import java.lang.{ Long => JLong }
-import java.math.{ BigInteger => JBigInteger, BigDecimal => JBigDecimal }
 
 class IBM4690PackedDecimalKnownLengthParser(
   e: ElementRuntimeData,
@@ -40,7 +43,7 @@ class IBM4690PackedDecimalRuntimeLengthParser(
   val e: ElementRuntimeData,
   binaryDecimalVirtualPoint: Int,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends PackedBinaryDecimalBaseParser(e, binaryDecimalVirtualPoint)
   with HasRuntimeExplicitLength {
 
@@ -49,11 +52,32 @@ class IBM4690PackedDecimalRuntimeLengthParser(
 
 }
 
+class IBM4690PackedDecimalPrefixedLengthParser(
+  e: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  binaryDecimalVirtualPoint: Int,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends PackedBinaryDecimalBaseParser(e, binaryDecimalVirtualPoint)
+  with PrefixedLengthParserMixin {
+
+  override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.ibm4690ToBigInteger(num)
+  override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = DecimalUtils.ibm4690ToBigDecimal(num, scale)
+  
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthParser)
+      
+  override def getBitLength(state: ParseOrUnparseState): Int = {
+    getPrefixedLengthInBits(state.asInstanceOf[PState]).toInt
+  }
+
+}
+
 class IBM4690PackedIntegerRuntimeLengthParser(
   val e: ElementRuntimeData,
   signed: Boolean,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends PackedBinaryIntegerBaseParser(e, signed)
   with HasRuntimeExplicitLength {
 
@@ -73,3 +97,25 @@ class IBM4690PackedIntegerKnownLengthParser(
   override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = DecimalUtils.ibm4690ToBigDecimal(num, scale)
 
 }
+
+
+class IBM4690PackedIntegerPrefixedLengthParser(
+  e: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  signed: Boolean,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends PackedBinaryIntegerBaseParser(e, signed)
+  with PrefixedLengthParserMixin {
+
+  override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.ibm4690ToBigInteger(num)
+  override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = DecimalUtils.ibm4690ToBigDecimal(num, scale)
+  
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthParser)
+      
+  override def getBitLength(state: ParseOrUnparseState): Int = {
+    getPrefixedLengthInBits(state.asInstanceOf[PState]).toInt
+  }
+}
+
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/PackedDecimalParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/PackedDecimalParsers.scala
index f8c827a..d08fe9a 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/PackedDecimalParsers.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/PackedDecimalParsers.scala
@@ -17,12 +17,15 @@
 
 package org.apache.daffodil.processors.parsers
 
+import java.lang.{ Long => JLong }
+import java.math.{ BigInteger => JBigInteger, BigDecimal => JBigDecimal }
+
+import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.Processor
+import org.apache.daffodil.processors.ParseOrUnparseState
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
-import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.util.{ DecimalUtils, PackedSignCodes }
-import java.lang.{ Long => JLong }
-import java.math.{ BigInteger => JBigInteger, BigDecimal => JBigDecimal }
 
 class PackedDecimalKnownLengthParser(
   e: ElementRuntimeData,
@@ -42,7 +45,7 @@ class PackedDecimalRuntimeLengthParser(
   binaryDecimalVirtualPoint: Int,
   packedSignCodes: PackedSignCodes,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends PackedBinaryDecimalBaseParser(e, binaryDecimalVirtualPoint)
   with HasRuntimeExplicitLength {
 
@@ -51,12 +54,35 @@ class PackedDecimalRuntimeLengthParser(
 
 }
 
+class PackedDecimalPrefixedLengthParser(
+  e: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  binaryDecimalVirtualPoint: Int,
+  packedSignCodes: PackedSignCodes,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends PackedBinaryDecimalBaseParser(e, binaryDecimalVirtualPoint)
+  with PrefixedLengthParserMixin {
+
+  override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.packedToBigInteger(num, packedSignCodes)
+  override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = DecimalUtils.packedToBigDecimal(num, scale, packedSignCodes)
+  
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthParser)
+      
+  override def getBitLength(state: ParseOrUnparseState): Int = {
+    getPrefixedLengthInBits(state.asInstanceOf[PState]).toInt
+  }
+
+}
+
+
 class PackedIntegerRuntimeLengthParser(
   val e: ElementRuntimeData,
   signed: Boolean,
   packedSignCodes: PackedSignCodes,
   val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits)
+  val lengthUnits: LengthUnits)
   extends PackedBinaryIntegerBaseParser(e, signed)
   with HasRuntimeExplicitLength {
 
@@ -77,3 +103,25 @@ class PackedIntegerKnownLengthParser(
   override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = DecimalUtils.packedToBigDecimal(num, scale, packedSignCodes)
 
 }
+
+class PackedIntegerPrefixedLengthParser(
+  e: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  signed: Boolean,
+  packedSignCodes: PackedSignCodes,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends PackedBinaryIntegerBaseParser(e, signed)
+  with PrefixedLengthParserMixin {
+
+  override def toBigInteger(num: Array[Byte]): JBigInteger = DecimalUtils.packedToBigInteger(num, packedSignCodes)
+  override def toBigDecimal(num: Array[Byte], scale: Int): JBigDecimal = DecimalUtils.packedToBigDecimal(num, scale, packedSignCodes)
+  
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthParser)
+      
+  override def getBitLength(state: ParseOrUnparseState): Int = {
+    getPrefixedLengthInBits(state.asInstanceOf[PState]).toInt
+  }
+}
+
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryBooleanParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryBooleanParsers.scala
index ad89e43..01c486f 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryBooleanParsers.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryBooleanParsers.scala
@@ -17,44 +17,34 @@
 
 package org.apache.daffodil.processors.parsers
 
-import org.apache.daffodil.processors.Evaluatable
-import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
-import org.apache.daffodil.processors.ElementRuntimeData
 import java.lang.{ Long => JLong, Boolean => JBoolean }
+
+import passera.unsigned.ULong
+
+import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.processors.ElementRuntimeData
+import org.apache.daffodil.processors.Evaluatable
 import org.apache.daffodil.processors.ParseOrUnparseState
-import org.apache.daffodil.util.Numbers
+import org.apache.daffodil.processors.Processor
 import org.apache.daffodil.schema.annotation.props.gen.LengthKind
-import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
 import org.apache.daffodil.util.MaybeULong
-import passera.unsigned.ULong
+import org.apache.daffodil.util.Numbers
 
-class BinaryBooleanParser(
-  val e: ElementRuntimeData,
+abstract class BinaryBooleanParserBase(
   binaryBooleanTrueRep: MaybeULong,
   binaryBooleanFalseRep: ULong,
-  val lengthEv: Evaluatable[JLong],
-  val lUnits: LengthUnits,
-  val lengthKind: LengthKind)
-  extends PrimParser() {
+  lengthUnits: LengthUnits)
+  extends PrimParser {
 
-  lazy val toBits = lUnits match {
+  def getBitLength(state: PState): Int
+
+  lazy val toBits = lengthUnits match {
     case LengthUnits.Bits => 1
     case LengthUnits.Bytes => 8
-    case _ => e.schemaDefinitionError("Binary Numbers must have length units of Bits or Bytes.")
-  }
-
-  def getBitLength(s: ParseOrUnparseState): Int = {
-    val nBytesAsJLong = lengthEv.evaluate(s)
-    val nBytes = Numbers.asInt(nBytesAsJLong)
-    lengthKind match {
-      case LengthKind.Implicit => nBytes
-      case _ => nBytes * toBits
-    }
+    case _ => context.schemaDefinitionError("Binary Numbers must have length units of Bits or Bytes.")
   }
 
-  override def context = e
-  override lazy val runtimeDependencies = Vector(lengthEv)
-
   override def parse(start: PState): Unit = {
     val nBits = getBitLength(start)
     if (nBits < 1 || nBits > 32) {
@@ -90,3 +80,45 @@ class BinaryBooleanParser(
     start.simpleElement.overwriteDataValue(bool)
   }
 }
+
+
+class BinaryBooleanParser(
+  override val context: ElementRuntimeData,
+  binaryBooleanTrueRep: MaybeULong,
+  binaryBooleanFalseRep: ULong,
+  lengthEv: Evaluatable[JLong],
+  lengthUnits: LengthUnits,
+  lengthKind: LengthKind)
+  extends BinaryBooleanParserBase(binaryBooleanTrueRep, binaryBooleanFalseRep, lengthUnits) {
+
+  override lazy val runtimeDependencies = Vector(lengthEv)
+
+  override def getBitLength(state: PState): Int = {
+    val nBytesAsJLong = lengthEv.evaluate(state)
+    val nBytes = Numbers.asInt(nBytesAsJLong)
+    lengthKind match {
+      case LengthKind.Implicit => nBytes
+      case _ => nBytes * toBits
+    }
+  }
+}
+
+
+class BinaryBooleanPrefixedLengthParser(
+  override val context: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  binaryBooleanTrueRep: MaybeULong,
+  binaryBooleanFalseRep: ULong,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends BinaryBooleanParserBase(binaryBooleanTrueRep, binaryBooleanFalseRep, lengthUnits)
+  with PrefixedLengthParserMixin {
+  
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthParser)
+  override val runtimeDependencies = Vector()
+
+  override def getBitLength(state: PState): Int = {
+    getPrefixedLengthInBits(state).toInt
+  }
+}
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryNumberParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryNumberParsers.scala
index 94e3af9..16c58dc 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryNumberParsers.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryNumberParsers.scala
@@ -17,12 +17,14 @@
 
 package org.apache.daffodil.processors.parsers
 
+import java.lang.{ Long => JLong, Number => JNumber, Double => JDouble, Float => JFloat }
+
+import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.Processor
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
-import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.schema.annotation.props.gen.YesNo
-import java.lang.{ Long => JLong, Number => JNumber, Double => JDouble, Float => JFloat }
-import org.apache.daffodil.processors.ParseOrUnparseState
 
 class BinaryFloatParser(override val context: ElementRuntimeData)
   extends PrimParser {
@@ -63,11 +65,30 @@ class BinaryDecimalKnownLengthParser(e: ElementRuntimeData, signed: YesNo, binar
   with HasKnownLengthInBits {
 }
 
-class BinaryDecimalRuntimeLengthParser(val e: ElementRuntimeData, signed: YesNo, binaryDecimalVirtualPoint: Int, val lengthEv: Evaluatable[JLong], val lUnits: LengthUnits)
+class BinaryDecimalRuntimeLengthParser(val e: ElementRuntimeData, signed: YesNo, binaryDecimalVirtualPoint: Int, val lengthEv: Evaluatable[JLong], val lengthUnits: LengthUnits)
   extends BinaryDecimalParserBase(e, signed, binaryDecimalVirtualPoint)
   with HasRuntimeExplicitLength {
 }
 
+class BinaryDecimalPrefixedLengthParser(
+  e: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  signed: YesNo,
+  binaryDecimalVirtualPoint: Int,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends BinaryDecimalParserBase(e, signed, binaryDecimalVirtualPoint)
+  with PrefixedLengthParserMixin {
+
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthParser)
+      
+  override def getBitLength(state: ParseOrUnparseState): Int = {
+    getPrefixedLengthInBits(state.asInstanceOf[PState]).toInt
+  }
+}
+
+
 abstract class BinaryDecimalParserBase(override val context: ElementRuntimeData, signed: YesNo, binaryDecimalVirtualPoint: Int)
   extends PrimParser {
   override lazy val runtimeDependencies = Vector()
@@ -91,7 +112,7 @@ abstract class BinaryDecimalParserBase(override val context: ElementRuntimeData,
   }
 }
 
-class BinaryIntegerRuntimeLengthParser(val e: ElementRuntimeData, signed: Boolean, val lengthEv: Evaluatable[JLong], val lUnits: LengthUnits)
+class BinaryIntegerRuntimeLengthParser(val e: ElementRuntimeData, signed: Boolean, val lengthEv: Evaluatable[JLong], val lengthUnits: LengthUnits)
   extends BinaryIntegerBaseParser(e, signed)
   with HasRuntimeExplicitLength {
 }
@@ -101,6 +122,24 @@ class BinaryIntegerKnownLengthParser(e: ElementRuntimeData, signed: Boolean, val
   with HasKnownLengthInBits {
 }
 
+class BinaryIntegerPrefixedLengthParser(
+  e: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  signed: Boolean,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends BinaryIntegerBaseParser(e, signed)
+  with PrefixedLengthParserMixin {
+
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthParser)
+      
+  override def getBitLength(state: ParseOrUnparseState): Int = {
+    getPrefixedLengthInBits(state.asInstanceOf[PState]).toInt
+  }
+}
+
+
 abstract class BinaryIntegerBaseParser(override val context: ElementRuntimeData, signed: Boolean)
   extends PrimParser {
   override lazy val runtimeDependencies = Vector()
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryNumberTraits.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryNumberTraits.scala
index e061b94..11b5b4d 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryNumberTraits.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BinaryNumberTraits.scala
@@ -17,12 +17,18 @@
 
 package org.apache.daffodil.processors.parsers
 
-import org.apache.daffodil.processors.ParseOrUnparseState
+import java.lang.{ Long => JLong }
+import java.lang.{ Number => JNumber }
+
+import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.infoset.DISimple
+import org.apache.daffodil.infoset.Infoset
+import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.ParseOrUnparseState
+import org.apache.daffodil.processors.Success
 import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
-import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.util.Numbers
-import java.lang.{ Long => JLong }
 
 trait HasKnownLengthInBits {
   def lengthInBits: Int
@@ -34,14 +40,14 @@ trait HasKnownLengthInBits {
 
 trait HasRuntimeExplicitLength {
   def e: ElementRuntimeData
-  def lUnits: LengthUnits // get at compile time, not runtime.
+  def lengthUnits: LengthUnits // get at compile time, not runtime.
   def lengthEv: Evaluatable[JLong]
 
   // binary numbers will use this conversion. Others won't.
-  lazy val toBits = lUnits match {
+  lazy val toBits = lengthUnits match {
     case LengthUnits.Bits => 1
     case LengthUnits.Bytes => 8
-    case _ => e.schemaDefinitionError("Binary Numbers must have length units of Bits or Bytes.")
+    case _ => Assert.invariantFailed("Binary Numbers should never have length units of Bits or Bytes.")
   }
 
   def getBitLength(s: ParseOrUnparseState): Int = {
@@ -50,3 +56,63 @@ trait HasRuntimeExplicitLength {
     nBytes * toBits
   }
 }
+
+
+trait PrefixedLengthParserMixin {
+
+  def prefixedLengthParser: Parser
+  def prefixedLengthERD: ElementRuntimeData
+  def lengthUnits: LengthUnits
+  def prefixedLengthAdjustmentInUnits: Long
+
+  /**
+   * Runs the prefixedLengthParser to determine the prefix length value, making
+   * adjustments as necessary. If the parse fails, this returns 0. The caller
+   * is expected to check to see if state.processorStatus is error upon
+   * returning, indicating that the returned value is meaningless.
+   */
+  def getPrefixedLengthInUnits(state: PState): Long = {
+    val savedInfoset = state.infoset
+
+    // create a "detached" element that the prefix length will be parsed to.
+    // This temporarily removes to infoset.
+    val plElement = Infoset.newElement(prefixedLengthERD, state.tunable).asInstanceOf[DISimple]
+    state.infoset = plElement
+
+    val parsedLen: JLong = try {
+      prefixedLengthParser.parse1(state)
+      // Return zero if there was an error parsing, the caller of this
+      // evaluatable should check the processorStatus to see if anything
+      // failed and ignore this zero. If there was no error, return the value
+      // as a long.
+      if (state.processorStatus ne Success) 0 else Numbers.asLong(plElement.dataValue)
+    } finally {
+      // reset back to the original infoset and throw away the detatched
+      // element
+      state.infoset = savedInfoset
+    }
+    if (parsedLen < 0) {
+      state.SDE("Prefixed length result must be non-negative, but was: %d", parsedLen)
+    }
+    val adjustedLen = parsedLen - prefixedLengthAdjustmentInUnits
+    if (adjustedLen < 0) {
+      state.SDE("Prefixed length result must be non-negative after dfdl:prefixIncludesPrefixLength adjustment , but was: %d", adjustedLen)
+    }
+    adjustedLen
+  }
+
+  /**
+   * Get the prefixed length in bits. If the parse fails, this returns 0. The
+   * caller is expected to check to see if state.processorStatus is error upon
+   * returning, indicating that the returned value is meaningless.
+   */
+  def getPrefixedLengthInBits(state: PState): Long = {
+    Assert.invariant(lengthUnits != LengthUnits.Characters)
+    val lenInUnits = getPrefixedLengthInUnits(state)
+    if (lengthUnits == LengthUnits.Bytes) {
+      lenInUnits * 8
+    } else {
+      lenInUnits
+    }
+  }
+}
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/HexBinaryLengthParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/HexBinaryLengthParsers.scala
index 981966a..484ab6d 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/HexBinaryLengthParsers.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/HexBinaryLengthParsers.scala
@@ -17,8 +17,13 @@
 
 package org.apache.daffodil.processors.parsers
 
+import java.lang.{ Long => JLong }
+
 import org.apache.daffodil.processors.ElementRuntimeData
 import org.apache.daffodil.processors.LengthInBitsEv
+import org.apache.daffodil.processors.Processor
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
+import org.apache.daffodil.util.Numbers
 
 sealed abstract class HexBinaryLengthParser(override val context: ElementRuntimeData)
   extends PrimParser {
@@ -62,3 +67,20 @@ final class HexBinaryEndOfBitLimitParser(erd: ElementRuntimeData)
     pstate.bitLimit0b.get - pstate.bitPos0b
   }
 }
+
+final class HexBinaryLengthPrefixedParser(
+  erd: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends HexBinaryLengthParser(erd)
+  with PrefixedLengthParserMixin {
+  
+  override def childProcessors: Vector[Processor] = Vector(prefixedLengthParser)
+  override val runtimeDependencies = Vector()
+
+  override def getLengthInBits(pstate: PState): Long = {
+    getPrefixedLengthInBits(pstate)
+  }
+}
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SpecifiedLengthParsers.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SpecifiedLengthParsers.scala
index a9fe8dc..94f73f4 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SpecifiedLengthParsers.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SpecifiedLengthParsers.scala
@@ -17,18 +17,21 @@
 
 package org.apache.daffodil.processors.parsers
 
-import org.apache.daffodil.util.Numbers
-import org.apache.daffodil.processors.ElementRuntimeData
-import org.apache.daffodil.processors.Evaluatable
-import org.apache.daffodil.processors.Success
-import org.apache.daffodil.util.OnStack
+import java.lang.{ Long => JLong }
 import java.util.regex.Matcher
-import org.apache.daffodil.exceptions.Assert
-import org.apache.daffodil.util.MaybeULong
+
 import passera.unsigned.ULong
+
 import org.apache.daffodil.equality._
-import java.lang.{ Long => JLong }
+import org.apache.daffodil.exceptions.Assert
+import org.apache.daffodil.processors.ElementRuntimeData
+import org.apache.daffodil.processors.Evaluatable
+import org.apache.daffodil.processors.Success
+import org.apache.daffodil.schema.annotation.props.gen.LengthUnits
 import org.apache.daffodil.util.Maybe
+import org.apache.daffodil.util.MaybeULong
+import org.apache.daffodil.util.Numbers
+import org.apache.daffodil.util.OnStack
 
 sealed abstract class SpecifiedLengthParserBase(
   eParser: Parser,
@@ -138,6 +141,23 @@ class SpecifiedLengthImplicitParser(
   final override def getBitLength(s: PState): MaybeULong = MaybeULong(nBits)
 }
 
+class SpecifiedLengthPrefixedParser(
+  eParser: Parser,
+  erd: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  override val lengthUnits: LengthUnits,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends SpecifiedLengthParserBase(eParser, erd)
+  with PrefixedLengthParserMixin {
+
+  override lazy val childProcessors = Vector(eParser, prefixedLengthParser)
+
+  final override def getBitLength(s: PState): MaybeULong = {
+    MaybeULong(getPrefixedLengthInBits(s))
+  }
+}
+
 /**
  * This is used when length is measured in characters, and couldn't be
  * converted to a computation on length in bits because a character is encoded as a variable number
@@ -217,6 +237,25 @@ final class SpecifiedLengthExplicitCharactersParser(
 
 }
 
+final class SpecifiedLengthPrefixedCharactersParser(
+  eParser: Parser,
+  erd: ElementRuntimeData,
+  override val prefixedLengthParser: Parser,
+  override val prefixedLengthERD: ElementRuntimeData,
+  override val prefixedLengthAdjustmentInUnits: Long)
+  extends SpecifiedLengthCharactersParserBase(eParser, erd)
+  with PrefixedLengthParserMixin {
+
+  override lazy val childProcessors = Vector(eParser, prefixedLengthParser)
+ 
+  override lazy val lengthUnits = LengthUnits.Characters
+   
+  def getCharLength(s: PState): Long = {
+    val nChars = getPrefixedLengthInUnits(s)
+    nChars
+  }
+}
+
 class CaptureStartOfContentLengthParser(override val context: ElementRuntimeData)
   extends PrimParser {
 
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/PrefixedTests.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/PrefixedTests.tdml
new file mode 100644
index 0000000..e451a42
--- /dev/null
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section12/lengthKind/PrefixedTests.tdml
@@ -0,0 +1,1995 @@
+<?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.
+-->
+
+<tdml:testSuite suiteName="PrefixedTests"
+  description="Section 12 - lengthKind=prefixed" xmlns:tdml="http://www.ibm.com/xmlns/dfdl/testData"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+  xmlns:fn="http://www.w3.org/2005/xpath-functions"
+  xmlns:ex="http://example.com"
+  xmlns:tns="http://example.com"
+  xmlns:daf="urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext"
+  defaultRoundTrip="onePass">
+
+  <tdml:defineSchema name="lengthKindPrefixed-text.dfdl.xsd">
+
+    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+
+    <dfdl:format ref="ex:GeneralFormat"
+      representation="text"
+      encoding="UTF-8"
+      binaryDecimalVirtualPoint="2"
+      nilKind="literalValue"
+      nilValue="%WSP+;"
+      textBooleanTrueRep="TRUE"
+      textBooleanFalseRep="FALSE"
+      prefixIncludesPrefixLength="no" />
+
+    <dfdl:defineFormat name="prefixedTxtByte">
+      <dfdl:format lengthKind="prefixed" lengthUnits="bytes" prefixLengthType="ex:threeByteTextInt" />
+    </dfdl:defineFormat>
+
+    <dfdl:defineFormat name="prefixedBinByte">
+      <dfdl:format lengthKind="prefixed" lengthUnits="bytes" prefixLengthType="ex:threeByteBinInt" />
+    </dfdl:defineFormat>
+
+    <dfdl:defineFormat name="prefixedTxtBits">
+      <dfdl:format lengthKind="prefixed" lengthUnits="bits" prefixLengthType="ex:twentyFourBitsTextInt" />
+    </dfdl:defineFormat>
+
+    <dfdl:defineFormat name="prefixedBinBits">
+      <dfdl:format lengthKind="prefixed" lengthUnits="bits" prefixLengthType="ex:twentyFourBitsBinInt" />
+    </dfdl:defineFormat>
+
+    <dfdl:defineFormat name="prefixedTxtChar">
+      <dfdl:format lengthKind="prefixed" lengthUnits="characters" prefixLengthType="ex:threeCharTextInt" />
+    </dfdl:defineFormat>
+
+
+    <xs:simpleType name="threeByteTextInt" dfdl:representation="text" dfdl:lengthKind="explicit"
+      dfdl:length="3" dfdl:lengthUnits="bytes">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="threeByteBinInt" dfdl:representation="binary" dfdl:lengthKind="explicit"
+      dfdl:length="3" dfdl:lengthUnits="bytes">
+      <xs:restriction base="xs:integer" />
+    </xs:simpleType>
+
+    <xs:simpleType name="twentyFourBitsTextInt" dfdl:representation="text" dfdl:lengthKind="explicit"
+      dfdl:length="24" dfdl:lengthUnits="bits">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="twentyFourBitsBinInt" dfdl:representation="binary" dfdl:lengthKind="explicit"
+      dfdl:length="24" dfdl:lengthUnits="bits">
+      <xs:restriction base="xs:integer" />
+    </xs:simpleType>
+
+    <xs:simpleType name="threeCharTextInt" dfdl:representation="text" dfdl:lengthKind="explicit"
+      dfdl:length="3" dfdl:lengthUnits="characters" dfdl:textNumberJustification="left"
+      dfdl:textPadKind="padChar" dfdl:textTrimKind="padChar" dfdl:textNumberPadCharacter="X">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="nByteTextInt" dfdl:representation="text" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:threeByteTextInt" dfdl:lengthUnits="bytes">
+      <xs:restriction base="xs:integer" />
+    </xs:simpleType>
+
+
+
+    <xs:element name="pl_text_string_txt_bytes" type="xs:string" dfdl:ref="prefixedTxtByte"
+      nillable="true" /> 
+    <xs:element name="pl_text_string_txt_bits"  type="xs:string" dfdl:ref="prefixedTxtBits"
+      nillable="true" />
+    <xs:element name="pl_text_string_txt_chars" type="xs:string" dfdl:ref="prefixedTxtChar"
+      nillable="true" daf:parseUnparsePolicy="parseOnly" />
+
+    <xs:element name="pl_text_string_txt_bytes_includes" type="xs:string" dfdl:ref="prefixedTxtByte"
+      nillable="true" dfdl:prefixIncludesPrefixLength="yes" />
+    <xs:element name="pl_text_string_txt_bits_includes" type="xs:string" dfdl:ref="prefixedTxtBits"
+      nillable="true" dfdl:prefixIncludesPrefixLength="yes" />
+    <xs:element name="pl_text_string_txt_chars_includes" type="xs:string" dfdl:ref="prefixedTxtChar"
+      nillable="true"  dfdl:prefixIncludesPrefixLength="yes" daf:parseUnparsePolicy="parseOnly" />
+
+    <xs:element name="pl_text_string_bin_bytes" type="xs:string" dfdl:ref="prefixedBinByte"
+      nillable="true" />
+    <xs:element name="pl_text_string_bin_bits" type="xs:string" dfdl:ref="prefixedBinBits"
+     nillable="true" />
+ 
+    <xs:element name="pl_text_int_txt_bytes" type="xs:int" dfdl:ref="prefixedTxtByte" />
+    <xs:element name="pl_text_int_txt_bits" type="xs:int" dfdl:ref="prefixedTxtBits" />
+    <xs:element name="pl_text_int_txt_chars" type="xs:int" dfdl:ref="prefixedTxtChar"
+      daf:parseUnparsePolicy="parseOnly" />
+
+    <xs:element name="pl_text_int_bin_bytes" type="xs:int" dfdl:ref="prefixedBinByte" />
+    <xs:element name="pl_text_int_bin_bits" type="xs:int" dfdl:ref="prefixedBinBits" />
+
+    <xs:element name="pl_text_int_txt_bytes_includes" type="xs:int" dfdl:ref="prefixedTxtByte"
+      dfdl:prefixIncludesPrefixLength="yes" />
+    <xs:element name="pl_text_int_txt_bits_includes" type="xs:int" dfdl:ref="prefixedTxtBits"
+      dfdl:prefixIncludesPrefixLength="yes" />
+    <xs:element name="pl_text_int_txt_chars_includes" type="xs:int" dfdl:ref="prefixedTxtChar"
+      dfdl:prefixIncludesPrefixLength="yes" daf:parseUnparsePolicy="parseOnly" />
+
+    <xs:element name="pl_text_int_bin_bytes_includes" type="xs:int" dfdl:ref="prefixedBinByte"
+      dfdl:prefixIncludesPrefixLength="yes" />
+    <xs:element name="pl_text_int_bin_bits_includes" type="xs:int" dfdl:ref="prefixedBinBits"
+      dfdl:prefixIncludesPrefixLength="yes" />
+
+    <xs:element name="pl_text_dec_txt_bytes" type="xs:decimal" dfdl:ref="prefixedTxtByte" />
+    <xs:element name="pl_text_dec_txt_bits" type="xs:decimal" dfdl:ref="prefixedTxtBits" />
+    <xs:element name="pl_text_dec_txt_chars" type="xs:decimal" dfdl:ref="prefixedTxtChar"
+      daf:parseUnparsePolicy="parseOnly" />
+
+    <xs:element name="pl_text_dec_bin_bytes" type="xs:decimal" dfdl:ref="prefixedBinByte" />
+    <xs:element name="pl_text_dec_bin_bits" type="xs:decimal" dfdl:ref="prefixedBinBits" />
+
+    <xs:element name="pl_text_date_txt_bytes" type="xs:dateTime" dfdl:ref="prefixedTxtByte" />
+    <xs:element name="pl_text_date_txt_bits" type="xs:dateTime" dfdl:ref="prefixedTxtBits" />
+    <xs:element name="pl_text_date_txt_chars" type="xs:dateTime" dfdl:ref="prefixedTxtChar"
+      daf:parseUnparsePolicy="parseOnly" />
+
+    <xs:element name="pl_text_date_bin_bytes" type="xs:dateTime" dfdl:ref="prefixedBinByte" />
+    <xs:element name="pl_text_date_bin_bits" type="xs:dateTime" dfdl:ref="prefixedBinBits" />
+
+    <xs:element name="pl_text_bool_txt_bytes" type="xs:boolean" dfdl:ref="prefixedTxtByte" />
+    <xs:element name="pl_text_bool_txt_bits" type="xs:boolean" dfdl:ref="prefixedTxtBits" />
+    <xs:element name="pl_text_bool_txt_chars" type="xs:boolean" dfdl:ref="prefixedTxtChar"
+      daf:parseUnparsePolicy="parseOnly" />
+
+    <xs:element name="pl_text_bool_bin_bytes" type="xs:boolean" dfdl:ref="prefixedBinByte" />
+    <xs:element name="pl_text_bool_bin_bits" type="xs:boolean" dfdl:ref="prefixedBinBits" />
+
+    <xs:element name="pl_text_string_pl_txt_bytes" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:nByteTextInt" dfdl:lengthUnits="bytes" />
+
+    <xs:element name="pl_complex_bin_bytes">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="strings" dfdl:ref="prefixedBinByte">
+            <xs:complexType>
+              <xs:sequence dfdl:separator=",">
+                <xs:element name="str" type="xs:string" maxOccurs="unbounded" dfdl:lengthKind="delimited" />
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+          <xs:element name="remaining" type="xs:string" dfdl:lengthKind="delimited" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="pl_complex_bin_bits">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="strings" dfdl:ref="prefixedBinBits">
+            <xs:complexType>
+              <xs:sequence dfdl:separator=",">
+                <xs:element name="str" type="xs:string" maxOccurs="unbounded" dfdl:lengthKind="delimited" />
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+          <xs:element name="remaining" type="xs:string" dfdl:lengthKind="delimited" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="pl_complex_bin_bytes_suspension">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="lenValue" dfdl:ref="prefixedBinByte">
+            <xs:complexType>
+              <xs:sequence dfdl:separator=",">
+                <xs:element name="len" type="xs:int" dfdl:lengthKind="delimited"
+                  dfdl:outputValueCalc="{ dfdl:valueLength(../ex:value, 'bytes') + 3 }" />
+                <xs:element name="value" type="xs:string" dfdl:lengthKind="explicit"
+                  dfdl:length="{ ../ex:len }" dfdl:textStringJustification="right"
+                  dfdl:textPadKind="padChar" dfdl:textTrimKind="padChar" dfdl:textStringPadCharacter="X" />
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+          <xs:element name="remaining" type="xs:string" dfdl:lengthKind="delimited" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+    <xs:element name="pl_complex_bin_bytes_suspension_includes">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="lenValue" dfdl:ref="prefixedBinByte" dfdl:prefixIncludesPrefixLength="yes">
+            <xs:complexType>
+              <xs:sequence dfdl:separator=",">
+                <xs:element name="len" type="xs:int" dfdl:lengthKind="delimited"
+                  dfdl:outputValueCalc="{ dfdl:valueLength(../ex:value, 'bytes') + 3 }" />
+                <xs:element name="value" type="xs:string" dfdl:lengthKind="explicit"
+                  dfdl:length="{ ../ex:len }" dfdl:textStringJustification="right"
+                  dfdl:textPadKind="padChar" dfdl:textTrimKind="padChar" dfdl:textStringPadCharacter="X" />
+              </xs:sequence>
+            </xs:complexType>
+          </xs:element>
+          <xs:element name="remaining" type="xs:string" dfdl:lengthKind="delimited" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+  </tdml:defineSchema>
+
+  <tdml:defineSchema name="lengthKindPrefixed-bin.dfdl.xsd">
+
+    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+
+    <dfdl:format ref="ex:GeneralFormat"
+      representation="binary"
+      encoding="UTF-8"
+      binaryDecimalVirtualPoint="2"
+      binaryBooleanTrueRep=""
+      binaryBooleanFalseRep="0"
+      binaryPackedSignCodes="C D F C"
+      binaryNumberCheckPolicy="strict"
+      calendarPatternKind="explicit"
+      calendarPattern="MMddyyyyHHmmss"
+      prefixIncludesPrefixLength="no" />
+
+    <dfdl:defineFormat name="prefixedTxtByte">
+      <dfdl:format lengthKind="prefixed" lengthUnits="bytes" prefixLengthType="ex:threeByteTextInt" />
+    </dfdl:defineFormat>
+
+    <dfdl:defineFormat name="prefixedBinByte">
+      <dfdl:format lengthKind="prefixed" lengthUnits="bytes" prefixLengthType="ex:threeByteBinInt" />
+    </dfdl:defineFormat>
+
+    <dfdl:defineFormat name="prefixedTxtBits">
+      <dfdl:format lengthKind="prefixed" lengthUnits="bits"  prefixLengthType="ex:twentyFourBitsTextInt" />
+    </dfdl:defineFormat>
+
+    <dfdl:defineFormat name="prefixedBinBits">
+      <dfdl:format lengthKind="prefixed" lengthUnits="bits"  prefixLengthType="ex:twentyFourBitsBinInt" />
+    </dfdl:defineFormat>
+
+    <dfdl:defineFormat name="prefixedTxtChar">
+      <dfdl:format lengthKind="prefixed" lengthUnits="characters" prefixLengthType="ex:threeCharTextInt" />
+    </dfdl:defineFormat>
+
+
+    <xs:simpleType name="threeByteTextInt" dfdl:representation="text" dfdl:lengthKind="explicit"
+      dfdl:length="3" dfdl:lengthUnits="bytes">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="threeByteBinInt" dfdl:representation="binary" dfdl:lengthKind="explicit"
+      dfdl:length="3" dfdl:lengthUnits="bytes">
+      <xs:restriction base="xs:integer" />
+    </xs:simpleType>
+
+    <xs:simpleType name="twentyFourBitsTextInt" dfdl:representation="text" dfdl:lengthKind="explicit"
+      dfdl:length="24" dfdl:lengthUnits="bits">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="twentyFourBitsBinInt" dfdl:representation="binary" dfdl:lengthKind="explicit"
+      dfdl:length="24" dfdl:lengthUnits="bits">
+      <xs:restriction base="xs:integer" />
+    </xs:simpleType>
+
+    <xs:simpleType name="threeCharTextInt" dfdl:representation="text" dfdl:lengthKind="explicit"
+      dfdl:length="3" dfdl:lengthUnits="characters" dfdl:textNumberJustification="left"
+      dfdl:textPadKind="padChar" dfdl:textTrimKind="padChar" dfdl:textNumberPadCharacter="X">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="nByteTextInt" dfdl:representation="text" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:threeByteTextInt" dfdl:lengthUnits="bytes">
+      <xs:restriction base="xs:integer" />
+    </xs:simpleType>
+
+
+    <xs:element name="pl_bin_int_txt_bytes" type="xs:int" dfdl:ref="prefixedTxtByte" />
+    <xs:element name="pl_bin_int_txt_bits" type="xs:int" dfdl:ref="prefixedTxtBits" />
+
+    <xs:element name="pl_bin_int_bin_bytes" type="xs:int" dfdl:ref="prefixedBinByte" />
+    <xs:element name="pl_bin_int_bin_bits" type="xs:int" dfdl:ref="prefixedBinBits" />
+
+    <xs:element name="pl_bin_int_txt_bytes_includes" type="xs:int" dfdl:ref="prefixedTxtByte"
+      dfdl:prefixIncludesPrefixLength="yes" />
+    <xs:element name="pl_bin_int_txt_bits_includes" type="xs:int" dfdl:ref="prefixedTxtBits"
+      dfdl:prefixIncludesPrefixLength="yes" />
+
+    <xs:element name="pl_bin_int_bin_bytes_includes" type="xs:int" dfdl:ref="prefixedBinByte"
+      dfdl:prefixIncludesPrefixLength="yes" />
+    <xs:element name="pl_bin_int_bin_bits_includes" type="xs:int" dfdl:ref="prefixedBinBits"
+      dfdl:prefixIncludesPrefixLength="yes" />
+
+    <xs:element name="pl_bin_int_bin_bytes_packed" type="xs:int" dfdl:ref="prefixedBinByte"
+      dfdl:binaryNumberRep="packed" />
+    <xs:element name="pl_bin_int_bin_bits_packed" type="xs:int" dfdl:ref="prefixedBinBits"
+      dfdl:binaryNumberRep="packed" />
+
+    <xs:element name="pl_bin_int_bin_bytes_bcd" type="xs:unsignedInt" dfdl:ref="prefixedBinByte"
+      dfdl:binaryNumberRep="bcd" />
+    <xs:element name="pl_bin_int_bin_bits_bcd" type="xs:unsignedInt" dfdl:ref="prefixedBinBits"
+      dfdl:binaryNumberRep="bcd" />
+
+    <xs:element name="pl_bin_int_bin_bytes_ibm4690" type="xs:int" dfdl:ref="prefixedBinByte"
+      dfdl:binaryNumberRep="ibm4690Packed" />
+    <xs:element name="pl_bin_int_bin_bits_ibm4690" type="xs:int" dfdl:ref="prefixedBinBits"
+      dfdl:binaryNumberRep="ibm4690Packed" />
+
+    <xs:element name="pl_bin_dec_txt_bytes" type="xs:decimal" dfdl:ref="prefixedTxtByte" />
+    <xs:element name="pl_bin_dec_txt_bits" type="xs:decimal" dfdl:ref="prefixedTxtBits" />
+
+    <xs:element name="pl_bin_dec_bin_bytes" type="xs:decimal" dfdl:ref="prefixedBinByte" />
+    <xs:element name="pl_bin_dec_bin_bits" type="xs:decimal" dfdl:ref="prefixedBinBits" />
+
+    <xs:element name="pl_bin_dec_bin_bytes_packed" type="xs:decimal" dfdl:ref="prefixedBinByte"
+      dfdl:binaryNumberRep="packed" />
+    <xs:element name="pl_bin_dec_bin_bits_packed" type="xs:decimal" dfdl:ref="prefixedBinBits"
+      dfdl:binaryNumberRep="packed" />
+
+    <xs:element name="pl_bin_dec_bin_bytes_bcd" type="xs:decimal" dfdl:ref="prefixedBinByte"
+      dfdl:binaryNumberRep="bcd" />
+    <xs:element name="pl_bin_dec_bin_bits_bcd" type="xs:decimal" dfdl:ref="prefixedBinBits"
+      dfdl:binaryNumberRep="bcd" />
+
+    <xs:element name="pl_bin_dec_bin_bytes_ibm4690" type="xs:decimal" dfdl:ref="prefixedBinByte"
+      dfdl:binaryNumberRep="ibm4690Packed" />
+    <xs:element name="pl_bin_dec_bin_bits_ibm4690" type="xs:decimal" dfdl:ref="prefixedBinBits"
+      dfdl:binaryNumberRep="ibm4690Packed" />
+
+    <xs:element name="pl_bin_hex_txt_bytes" type="xs:hexBinary" dfdl:ref="prefixedTxtByte" />
+    <xs:element name="pl_bin_hex_txt_bits" type="xs:hexBinary" dfdl:ref="prefixedTxtBits" />
+
+    <xs:element name="pl_bin_hex_bin_bytes" type="xs:hexBinary" dfdl:ref="prefixedBinByte" />
+    <xs:element name="pl_bin_hex_bin_bits" type="xs:hexBinary" dfdl:ref="prefixedBinBits" />
+
+    <xs:element name="pl_bin_bool_txt_bytes" type="xs:boolean" dfdl:ref="prefixedTxtByte" />
+    <xs:element name="pl_bin_bool_txt_bits" type="xs:boolean" dfdl:ref="prefixedTxtBits" />
+
+    <xs:element name="pl_bin_bool_bin_bytes" type="xs:boolean" dfdl:ref="prefixedBinByte" />
+    <xs:element name="pl_bin_bool_bin_bits" type="xs:boolean" dfdl:ref="prefixedBinBits" />
+    
+    <xs:element name="pl_bin_date_bin_bytes_packed" type="xs:dateTime" dfdl:ref="prefixedBinByte"
+      dfdl:binaryCalendarRep="packed" />
+    <xs:element name="pl_bin_date_bin_bits_packed" type="xs:dateTime" dfdl:ref="prefixedBinBits"
+      dfdl:binaryCalendarRep="packed" />
+
+    <xs:element name="pl_bin_date_bin_bytes_bcd" type="xs:dateTime" dfdl:ref="prefixedBinByte"
+      dfdl:binaryCalendarRep="bcd" />
+    <xs:element name="pl_bin_date_bin_bits_bcd" type="xs:dateTime" dfdl:ref="prefixedBinBits"
+      dfdl:binaryCalendarRep="bcd" />
+
+    <xs:element name="pl_bin_date_bin_bytes_ibm4690" type="xs:dateTime" dfdl:ref="prefixedBinByte"
+      dfdl:binaryCalendarRep="ibm4690Packed" />
+    <xs:element name="pl_bin_date_bin_bits_ibm4690" type="xs:dateTime" dfdl:ref="prefixedBinBits"
+      dfdl:binaryCalendarRep="ibm4690Packed" />
+
+    <xs:simpleType name="plSlash1_string_prefix"
+       dfdl:lengthKind="explicit" dfdl:length="4" dfdl:lengthUnits="bytes">
+      <xs:restriction base="xs:unsignedByte" />
+    </xs:simpleType>
+
+    <xs:element name="plSlash1_data">
+      <xs:complexType>
+        <xs:sequence>
+          <xs:element name="string" type="xs:string" maxOccurs="unbounded"
+            dfdl:lengthKind="prefixed" dfdl:prefixLengthType="ex:plSlash1_string_prefix"
+            dfdl:lengthUnits="bytes" dfdl:alignment="4" dfdl:alignmentUnits="bytes" dfdl:fillByte="%NUL;" />
+        </xs:sequence>
+      </xs:complexType>
+    </xs:element>
+
+  </tdml:defineSchema>
+
+  <tdml:defineSchema name="lengthKindPrefixed-sde.dfdl.xsd">
+
+    <xs:include schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd" />
+
+    <dfdl:format ref="ex:GeneralFormat"
+      prefixIncludesPrefixLength="no" />
+
+    <xs:complexType name="prefixComplex">
+      <xs:sequence>
+        <xs:element name="foo" type="xs:int" dfdl:lengthKind="explicit"
+          dfdl:length="3" dfdl:lengthUnits="bytes" />
+      </xs:sequence>
+    </xs:complexType>
+
+    <xs:simpleType name="prefixDelimited" dfdl:lengthKind="delimited">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixEndOfParent" dfdl:lengthKind="endOfParent">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixPattern" dfdl:lengthKind="pattern" dfdl:lengthPattern="[0-9]{1,2}">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixExpression" dfdl:lengthKind="explicit" dfdl:length="{ fn:count(.) }">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixOVC" dfdl:lengthKind="explicit" dfdl:length="2" dfdl:outputValueCalc="{ 5 }" >
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixInitiator" dfdl:lengthKind="explicit" dfdl:length="2" dfdl:initiator="i">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixTerminator" dfdl:lengthKind="explicit" dfdl:length="2" dfdl:terminator="t">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixAlignment" dfdl:lengthKind="explicit" dfdl:length="2" dfdl:alignment="8"
+      dfdl:alignmentUnits="bits">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixLeadingSkip" dfdl:lengthKind="explicit" dfdl:length="2" dfdl:leadingSkip="1">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixTrailingSkip" dfdl:lengthKind="explicit" dfdl:length="2" dfdl:trailingSkip="1">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixLengthUnits" dfdl:lengthKind="explicit" dfdl:length="8" dfdl:lengthUnits="bits">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixLengthNest1" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="prefixLengthNest2">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixLengthNest2" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="prefixLengthNest3">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixLengthNest3" dfdl:lengthKind="explicit" dfdl:length="2">
+      <xs:restriction base="xs:integer" /> 
+    </xs:simpleType>
+
+    <xs:simpleType name="prefixLengthDecimal" dfdl:lengthKind="explicit" dfdl:length="2">
+      <xs:restriction base="xs:decimal" /> 
+    </xs:simpleType>
+
+    <xs:element name="pl_complex" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixComplex" />
+    <xs:element name="pl_delimited" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixDelimited" />
+    <xs:element name="pl_endofparent" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixEndOfParent" />
+    <xs:element name="pl_pattern" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixPattern" />
+    <xs:element name="pl_expression" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixExpression" />
+    <xs:element name="pl_ovc" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixOVC" />
+    <xs:element name="pl_initiator" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixInitiator" />
+    <xs:element name="pl_terminator" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixTerminator" />
+    <xs:element name="pl_alignment" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixAlignment" />
+    <xs:element name="pl_leadingskip" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixLeadingSkip" />
+    <xs:element name="pl_trailingskip" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixTrailingSkip" />
+    <xs:element name="pl_lengthunits" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixLengthUnits" />
+    <xs:element name="pl_nest" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixLengthNest1" />
+    <xs:element name="pl_decimal" type="xs:string" dfdl:lengthKind="prefixed"
+      dfdl:prefixLengthType="ex:prefixLengthDecimal" />
+
+  </tdml:defineSchema>
+
+
+  <tdml:parserTestCase name="pl_text_string_txt_bytes" roundTrip="twoPass"
+    root="pl_text_string_txt_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">006</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <ex:pl_text_string_txt_bytes>ábcde</ex:pl_text_string_txt_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_txt_bits" roundTrip="twoPass"
+    root="pl_text_string_txt_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">048</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_txt_bits>ábcde</pl_text_string_txt_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    DAFFODIL-2029: Cannot roundTrip due to unimplemented unparsing with
+    dfdl:lengthKind="prefixed" and dfdl:lengthUnits="characters"
+  -->
+  <tdml:parserTestCase name="pl_text_string_txt_chars" roundTrip="false"
+    root="pl_text_string_txt_chars"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">005</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_txt_chars>ábcde</pl_text_string_txt_chars>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_txt_bytes_includes" roundTrip="twoPass"
+    root="pl_text_string_txt_bytes_includes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">009</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <ex:pl_text_string_txt_bytes_includes>ábcde</ex:pl_text_string_txt_bytes_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_txt_bits_includes" roundTrip="twoPass"
+    root="pl_text_string_txt_bits_includes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">072</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_txt_bits_includes>ábcde</pl_text_string_txt_bits_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    DAFFODIL-2029: Cannot roundTrip due to unimplemented unparsing with
+    dfdl:lengthKind="prefixed" and dfdl:lengthUnits="characters"
+  -->
+  <tdml:parserTestCase name="pl_text_string_txt_chars_includes" roundTrip="false"
+    root="pl_text_string_txt_chars_includes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">008</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_txt_chars_includes>ábcde</pl_text_string_txt_chars_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    DAFFODIL-2029: Cannot roundTrip due to unimplemented unparsing with
+    dfdl:lengthKind="prefixed" and dfdl:lengthUnits="characters"
+  -->
+  <tdml:parserTestCase name="pl_text_string_txt_chars_padding" roundTrip="false"
+    root="pl_text_string_txt_chars"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">5XX</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_txt_chars>ábcde</pl_text_string_txt_chars>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_bin_bytes"
+    root="pl_text_string_bin_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 06</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_bin_bytes>ábcde</pl_text_string_bin_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_bin_bits"
+    root="pl_text_string_bin_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 30</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_bin_bits>ábcde</pl_text_string_bin_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_txt_bytes_nil" roundTrip="twoPass"
+    root="pl_text_string_txt_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">006</tdml:documentPart>
+      <tdml:documentPart type="text">      </tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_txt_bytes xsi:nil="true" />
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_txt_bits_nil" roundTrip="twoPass"
+    root="pl_text_string_txt_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">048</tdml:documentPart>
+      <tdml:documentPart type="text">      </tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_txt_bits xsi:nil="true" />
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    DAFFODIL-2029: Cannot roundTrip due to unimplemented unparsing with
+    dfdl:lengthKind="prefixed" and dfdl:lengthUnits="characters"
+  -->
+  <tdml:parserTestCase name="pl_text_string_txt_chars_nil" roundTrip="false"
+    root="pl_text_string_txt_chars"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">005</tdml:documentPart>
+      <tdml:documentPart type="text">     </tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_txt_chars xsi:nil="true" />
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_bin_bytes_nil" roundTrip="twoPass"
+    root="pl_text_string_bin_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 06</tdml:documentPart>
+      <tdml:documentPart type="text">      </tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_bin_bytes xsi:nil="true" />
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_bin_bits_nil" roundTrip="twoPass"
+    root="pl_text_string_bin_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 30</tdml:documentPart>
+      <tdml:documentPart type="text">      </tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_bin_bits xsi:nil="true" />
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_txt_bytes_neg_len"
+    root="pl_text_string_txt_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">-06</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Runtime Schema Definition Error</tdml:error>
+      <tdml:error>Prefixed length</tdml:error>
+      <tdml:error>non-negative</tdml:error>
+      <tdml:error>-6</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_txt_bytes_not_enough_data"
+    root="pl_text_string_txt_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">006</tdml:documentPart>
+      <tdml:documentPart type="text">abcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Parse Error</tdml:error>
+      <tdml:error>Insufficient bits in data</tdml:error>
+      <tdml:error>48</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_txt_bytes_not_enough_prefix_data"
+    root="pl_text_string_txt_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">01</tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Parse Error</tdml:error>
+      <tdml:error>Insufficient bits in data</tdml:error>
+      <tdml:error>24</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_string_pl_txt_bytes"
+    root="pl_text_string_pl_txt_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">002</tdml:documentPart>
+      <tdml:documentPart type="text">06</tdml:documentPart>
+      <tdml:documentPart type="text">ábcde</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_string_pl_txt_bytes>ábcde</pl_text_string_pl_txt_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_int_txt_bytes" roundTrip="twoPass"
+    root="pl_text_int_txt_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">002</tdml:documentPart>
+      <tdml:documentPart type="text">12</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_int_txt_bytes>12</pl_text_int_txt_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_int_txt_bits" roundTrip="twoPass"
+    root="pl_text_int_txt_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">016</tdml:documentPart>
+      <tdml:documentPart type="text">12</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_int_txt_bits>12</pl_text_int_txt_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    DAFFODIL-2029: Cannot roundTrip due to unimplemented unparsing with
+    dfdl:lengthKind="prefixed" and dfdl:lengthUnits="characters"
+  -->
+  <tdml:parserTestCase name="pl_text_int_txt_chars" roundTrip="false"
+    root="pl_text_int_txt_chars"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">002</tdml:documentPart>
+      <tdml:documentPart type="text">12</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_int_txt_chars>12</pl_text_int_txt_chars>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_int_bin_bytes"
+    root="pl_text_int_bin_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 02</tdml:documentPart>
+      <tdml:documentPart type="text">12</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_int_bin_bytes>12</pl_text_int_bin_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_int_bin_bits"
+    root="pl_text_int_bin_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 10</tdml:documentPart>
+      <tdml:documentPart type="text">12</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_int_bin_bits>12</pl_text_int_bin_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_int_txt_bytes_includes" roundTrip="twoPass"
+    root="pl_text_int_txt_bytes_includes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">005</tdml:documentPart>
+      <tdml:documentPart type="text">12</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_int_txt_bytes_includes>12</pl_text_int_txt_bytes_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_int_txt_bits_includes" roundTrip="twoPass"
+    root="pl_text_int_txt_bits_includes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">040</tdml:documentPart>
+      <tdml:documentPart type="text">12</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_int_txt_bits_includes>12</pl_text_int_txt_bits_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    DAFFODIL-2029: Cannot roundTrip due to unimplemented unparsing with
+    dfdl:lengthKind="prefixed" and dfdl:lengthUnits="characters"
+  -->
+  <tdml:parserTestCase name="pl_text_int_txt_chars_includes" roundTrip="false"
+    root="pl_text_int_txt_chars_includes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">005</tdml:documentPart>
+      <tdml:documentPart type="text">12</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_int_txt_chars_includes>12</pl_text_int_txt_chars_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_int_bin_bytes_includes"
+    root="pl_text_int_bin_bytes_includes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 05</tdml:documentPart>
+      <tdml:documentPart type="text">12</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_int_bin_bytes_includes>12</pl_text_int_bin_bytes_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_int_bin_bits_includes"
+    root="pl_text_int_bin_bits_includes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 28</tdml:documentPart>
+      <tdml:documentPart type="text">12</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_int_bin_bits_includes>12</pl_text_int_bin_bits_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_dec_txt_bytes" roundTrip="twoPass"
+    root="pl_text_dec_txt_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">006</tdml:documentPart>
+      <tdml:documentPart type="text">123.45</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_dec_txt_bytes>123.45</pl_text_dec_txt_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_dec_txt_bits" roundTrip="twoPass"
+    root="pl_text_dec_txt_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">048</tdml:documentPart>
+      <tdml:documentPart type="text">123.45</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_dec_txt_bits>123.45</pl_text_dec_txt_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+
+  <!--
+    DAFFODIL-2029: Cannot roundTrip due to unimplemented unparsing with
+    dfdl:lengthKind="prefixed" and dfdl:lengthUnits="characters"
+  -->
+  <tdml:parserTestCase name="pl_text_dec_txt_chars" roundTrip="false"
+    root="pl_text_dec_txt_chars"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">006</tdml:documentPart>
+      <tdml:documentPart type="text">123.45</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_dec_txt_chars>123.45</pl_text_dec_txt_chars>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_dec_bin_bytes"
+    root="pl_text_dec_bin_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 06</tdml:documentPart>
+      <tdml:documentPart type="text">123.45</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_dec_bin_bytes>123.45</pl_text_dec_bin_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_dec_bin_bits"
+    root="pl_text_dec_bin_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 30</tdml:documentPart>
+      <tdml:documentPart type="text">123.45</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_dec_bin_bits>123.45</pl_text_dec_bin_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_date_txt_bytes" roundTrip="twoPass"
+    root="pl_text_date_txt_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">019</tdml:documentPart>
+      <tdml:documentPart type="text">2017-08-28T18:29:00</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_date_txt_bytes>2017-08-28T18:29:00</pl_text_date_txt_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_date_txt_bits"
+    root="pl_text_date_txt_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">152</tdml:documentPart>
+      <tdml:documentPart type="text">2017-08-28T18:29:00</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_date_txt_bits>2017-08-28T18:29:00</pl_text_date_txt_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    DAFFODIL-2029: Cannot roundTrip due to unimplemented unparsing with
+    dfdl:lengthKind="prefixed" and dfdl:lengthUnits="characters"
+  -->
+  <tdml:parserTestCase name="pl_text_date_txt_chars" roundTrip="false"
+    root="pl_text_date_txt_chars"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">019</tdml:documentPart>
+      <tdml:documentPart type="text">2017-08-28T18:29:00</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_date_txt_chars>2017-08-28T18:29:00</pl_text_date_txt_chars>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_date_bin_bytes"
+    root="pl_text_date_bin_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 13</tdml:documentPart>
+      <tdml:documentPart type="text">2017-08-28T18:29:00</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_date_bin_bytes>2017-08-28T18:29:00</pl_text_date_bin_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_date_bin_bits"
+    root="pl_text_date_bin_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 98</tdml:documentPart>
+      <tdml:documentPart type="text">2017-08-28T18:29:00</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_date_bin_bits>2017-08-28T18:29:00</pl_text_date_bin_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_bool_txt_bytes" roundTrip="twoPass"
+    root="pl_text_bool_txt_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">004</tdml:documentPart>
+      <tdml:documentPart type="text">TRUE</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_bool_txt_bytes>true</pl_text_bool_txt_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_bool_txt_bits" roundTrip="twoPass"
+    root="pl_text_bool_txt_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">032</tdml:documentPart>
+      <tdml:documentPart type="text">TRUE</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_bool_txt_bits>true</pl_text_bool_txt_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <!--
+    DAFFODIL-2029: Cannot roundTrip due to unimplemented unparsing with
+    dfdl:lengthKind="prefixed" and dfdl:lengthUnits="characters"
+  -->
+  <tdml:parserTestCase name="pl_text_bool_txt_chars" roundTrip="false"
+    root="pl_text_bool_txt_chars"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">004</tdml:documentPart>
+      <tdml:documentPart type="text">TRUE</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_bool_txt_chars>true</pl_text_bool_txt_chars>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_bool_bin_bytes"
+    root="pl_text_bool_bin_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 04</tdml:documentPart>
+      <tdml:documentPart type="text">TRUE</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_bool_bin_bytes>true</pl_text_bool_bin_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_text_bool_bin_bits"
+    root="pl_text_bool_bin_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 20</tdml:documentPart>
+      <tdml:documentPart type="text">TRUE</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_text_bool_bin_bits>true</pl_text_bool_bin_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_txt_bytes" roundTrip="twoPass"
+    root="pl_bin_int_txt_bytes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">002</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_txt_bytes>12345</pl_bin_int_txt_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_txt_bits" roundTrip="twoPass"
+    root="pl_bin_int_txt_bits"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">016</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_txt_bits>12345</pl_bin_int_txt_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_bin_bytes" roundTrip="twoPass"
+    root="pl_bin_int_bin_bytes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 02</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_bin_bytes>12345</pl_bin_int_bin_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_bin_bits" roundTrip="twoPass"
+    root="pl_bin_int_bin_bits"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 10</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_bin_bits>12345</pl_bin_int_bin_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_txt_bytes_includes" roundTrip="twoPass"
+    root="pl_bin_int_txt_bytes_includes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">005</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_txt_bytes_includes>12345</pl_bin_int_txt_bytes_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_txt_bits_includes" roundTrip="twoPass"
+    root="pl_bin_int_txt_bits_includes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">040</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_txt_bits_includes>12345</pl_bin_int_txt_bits_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_bin_bytes_includes" roundTrip="twoPass"
+    root="pl_bin_int_bin_bytes_includes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 05</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_bin_bytes_includes>12345</pl_bin_int_bin_bytes_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_bin_bits_includes" roundTrip="twoPass"
+    root="pl_bin_int_bin_bits_includes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 28</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_bin_bits_includes>12345</pl_bin_int_bin_bits_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_bin_bytes_packed"
+    root="pl_bin_int_bin_bytes_packed"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 03</tdml:documentPart>
+      <tdml:documentPart type="byte">01234C</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_bin_bytes_packed>1234</pl_bin_int_bin_bytes_packed>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+      
+  <tdml:parserTestCase name="pl_bin_int_bin_bits_packed"
+    root="pl_bin_int_bin_bits_packed"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 18</tdml:documentPart>
+      <tdml:documentPart type="byte">01234C</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_bin_bits_packed>1234</pl_bin_int_bin_bits_packed>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_bin_bytes_bcd"
+    root="pl_bin_int_bin_bytes_bcd"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 02</tdml:documentPart>
+      <tdml:documentPart type="byte">1234</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_bin_bytes_bcd>1234</pl_bin_int_bin_bytes_bcd>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+      
+  <tdml:parserTestCase name="pl_bin_int_bin_bits_bcd"
+    root="pl_bin_int_bin_bits_bcd"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 10</tdml:documentPart>
+      <tdml:documentPart type="byte">1234</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_bin_bits_bcd>1234</pl_bin_int_bin_bits_bcd>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_int_bin_bytes_ibm4690"
+    root="pl_bin_int_bin_bytes_ibm4690"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 02</tdml:documentPart>
+      <tdml:documentPart type="byte">1234</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_bin_bytes_ibm4690>1234</pl_bin_int_bin_bytes_ibm4690>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+      
+  <tdml:parserTestCase name="pl_bin_int_bin_bits_ibm4690"
+    root="pl_bin_int_bin_bits_ibm4690"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 10</tdml:documentPart>
+      <tdml:documentPart type="byte">1234</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_int_bin_bits_ibm4690>1234</pl_bin_int_bin_bits_ibm4690>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_dec_txt_bytes" roundTrip="twoPass"
+    root="pl_bin_dec_txt_bytes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">002</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_dec_txt_bytes>123.45</pl_bin_dec_txt_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_dec_txt_bits" roundTrip="twoPass"
+    root="pl_bin_dec_txt_bits"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">016</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_dec_txt_bits>123.45</pl_bin_dec_txt_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_dec_bin_bytes"
+    root="pl_bin_dec_bin_bytes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 02</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_dec_bin_bytes>123.45</pl_bin_dec_bin_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_dec_bin_bits"
+    root="pl_bin_dec_bin_bits"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 10</tdml:documentPart>
+      <tdml:documentPart type="byte">30 39</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_dec_bin_bits>123.45</pl_bin_dec_bin_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_dec_bin_bytes_packed"
+    root="pl_bin_dec_bin_bytes_packed"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 03</tdml:documentPart>
+      <tdml:documentPart type="byte">01234C</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_dec_bin_bytes_packed>12.34</pl_bin_dec_bin_bytes_packed>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+      
+  <tdml:parserTestCase name="pl_bin_dec_bin_bits_packed"
+    root="pl_bin_dec_bin_bits_packed"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 18</tdml:documentPart>
+      <tdml:documentPart type="byte">01234C</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_dec_bin_bits_packed>12.34</pl_bin_dec_bin_bits_packed>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_dec_bin_bytes_bcd"
+    root="pl_bin_dec_bin_bytes_bcd"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 02</tdml:documentPart>
+      <tdml:documentPart type="byte">1234</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_dec_bin_bytes_bcd>12.34</pl_bin_dec_bin_bytes_bcd>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+      
+  <tdml:parserTestCase name="pl_bin_dec_bin_bits_bcd"
+    root="pl_bin_dec_bin_bits_bcd"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 10</tdml:documentPart>
+      <tdml:documentPart type="byte">1234</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_dec_bin_bits_bcd>12.34</pl_bin_dec_bin_bits_bcd>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_dec_bin_bytes_ibm4690"
+    root="pl_bin_dec_bin_bytes_ibm4690"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 02</tdml:documentPart>
+      <tdml:documentPart type="byte">1234</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_dec_bin_bytes_ibm4690>12.34</pl_bin_dec_bin_bytes_ibm4690>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+      
+  <tdml:parserTestCase name="pl_bin_dec_bin_bits_ibm4690"
+    root="pl_bin_dec_bin_bits_ibm4690"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 10</tdml:documentPart>
+      <tdml:documentPart type="byte">1234</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_dec_bin_bits_ibm4690>12.34</pl_bin_dec_bin_bits_ibm4690>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_hex_txt_bytes" roundTrip="twoPass"
+    root="pl_bin_hex_txt_bytes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">004</tdml:documentPart>
+      <tdml:documentPart type="byte">DE AD BE EF</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_hex_txt_bytes>DEADBEEF</pl_bin_hex_txt_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_hex_txt_bits" roundTrip="twoPass"
+    root="pl_bin_hex_txt_bits"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">032</tdml:documentPart>
+      <tdml:documentPart type="byte">DE AD BE EF</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_hex_txt_bits>DEADBEEF</pl_bin_hex_txt_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_hex_bin_bytes"
+    root="pl_bin_hex_bin_bytes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 04</tdml:documentPart>
+      <tdml:documentPart type="byte">DE AD BE EF</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_hex_bin_bytes>DEADBEEF</pl_bin_hex_bin_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_hex_bin_bits"
+    root="pl_bin_hex_bin_bits"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 20</tdml:documentPart>
+      <tdml:documentPart type="byte">DE AD BE EF</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_hex_bin_bits>DEADBEEF</pl_bin_hex_bin_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_bool_txt_bytes" roundTrip="twoPass"
+    root="pl_bin_bool_txt_bytes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">001</tdml:documentPart>
+      <tdml:documentPart type="byte">01</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_bool_txt_bytes>true</pl_bin_bool_txt_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_bool_txt_bits" roundTrip="twoPass"
+    root="pl_bin_bool_txt_bits"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text">008</tdml:documentPart>
+      <tdml:documentPart type="byte">01</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_bool_txt_bits>true</pl_bin_bool_txt_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_bool_bin_bytes" roundTrip="twoPass"
+    root="pl_bin_bool_bin_bytes"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 01</tdml:documentPart>
+      <tdml:documentPart type="byte">01</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_bool_bin_bytes>true</pl_bin_bool_bin_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_bool_bin_bits" roundTrip="twoPass"
+    root="pl_bin_bool_bin_bits"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 08</tdml:documentPart>
+      <tdml:documentPart type="byte">01</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_bool_bin_bits>true</pl_bin_bool_bin_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+
+  <tdml:parserTestCase name="pl_bin_date_bin_bytes_packed"
+    root="pl_bin_date_bin_bytes_packed"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 08</tdml:documentPart>
+      <tdml:documentPart type="byte">01 22 51 64 51 93 65 0C</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_date_bin_bytes_packed>1645-12-25T19:36:50</pl_bin_date_bin_bytes_packed>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_date_bin_bits_packed"
+    root="pl_bin_date_bin_bits_packed"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 40</tdml:documentPart>
+      <tdml:documentPart type="byte">01 22 51 64 51 93 65 0C</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_date_bin_bits_packed>1645-12-25T19:36:50</pl_bin_date_bin_bits_packed>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_date_bin_bytes_bcd"
+    root="pl_bin_date_bin_bytes_bcd"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 07</tdml:documentPart>
+      <tdml:documentPart type="byte">06 14 20 04 18 56 03</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_date_bin_bytes_bcd>2004-06-14T18:56:03</pl_bin_date_bin_bytes_bcd>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_date_bin_bits_bcd"
+    root="pl_bin_date_bin_bits_bcd"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 38</tdml:documentPart>
+      <tdml:documentPart type="byte">06 14 20 04 18 56 03</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_date_bin_bits_bcd>2004-06-14T18:56:03</pl_bin_date_bin_bits_bcd>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_date_bin_bytes_ibm4690"
+    root="pl_bin_date_bin_bytes_ibm4690"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 07</tdml:documentPart>
+      <tdml:documentPart type="byte">11 30 20 07 04 15 08</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_date_bin_bytes_ibm4690>2007-11-30T04:15:08</pl_bin_date_bin_bytes_ibm4690>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_bin_date_bin_bits_ibm4690"
+    root="pl_bin_date_bin_bits_ibm4690"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 38</tdml:documentPart>
+      <tdml:documentPart type="byte">11 30 20 07 04 15 08</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_bin_date_bin_bits_ibm4690>2007-11-30T04:15:08</pl_bin_date_bin_bits_ibm4690>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="plSlash1_data"
+    root="plSlash1_data"
+    model="lengthKindPrefixed-bin.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 00 07</tdml:documentPart>
+      <tdml:documentPart type="text">abcdefg</tdml:documentPart>
+      <tdml:documentPart type="byte">00</tdml:documentPart>
+      <tdml:documentPart type="byte">00 00 00 07</tdml:documentPart>
+      <tdml:documentPart type="text">ABCDEFG</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <plSlash1_data>
+          <string>abcdefg</string>
+          <string>ABCDEFG</string>
+        </plSlash1_data>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+
+  <tdml:parserTestCase name="pl_complex_bin_bytes"
+    root="pl_complex_bin_bytes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 0D</tdml:documentPart>
+      <tdml:documentPart type="text">one,two,threeremaining</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_complex_bin_bytes>
+          <strings>
+            <str>one</str>
+            <str>two</str>
+            <str>three</str>
+          </strings>
+          <remaining>remaining</remaining>
+        </pl_complex_bin_bytes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_complex_bin_bits"
+    root="pl_complex_bin_bits"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 68</tdml:documentPart>
+      <tdml:documentPart type="text">one,two,threeremaining</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_complex_bin_bits>
+          <strings>
+            <str>one</str>
+            <str>two</str>
+            <str>three</str>
+          </strings>
+          <remaining>remaining</remaining>
+        </pl_complex_bin_bits>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_complex_bin_bytes_suspension"
+    root="pl_complex_bin_bytes_suspension"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 0A</tdml:documentPart>
+      <tdml:documentPart type="text">8,XXXthreeremaining</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_complex_bin_bytes_suspension>
+          <lenValue>
+            <len>8</len>
+            <value>three</value>
+          </lenValue>
+          <remaining>remaining</remaining>
+        </pl_complex_bin_bytes_suspension>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_complex_bin_bytes_suspension_includes"
+    root="pl_complex_bin_bytes_suspension_includes"
+    model="lengthKindPrefixed-text.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="byte">00 00 0D</tdml:documentPart>
+      <tdml:documentPart type="text">8,XXXthreeremaining</tdml:documentPart>
+    </tdml:document>
+    <tdml:infoset>
+      <tdml:dfdlInfoset>
+        <pl_complex_bin_bytes_suspension_includes>
+          <lenValue>
+            <len>8</len>
+            <value>three</value>
+          </lenValue>
+          <remaining>remaining</remaining>
+        </pl_complex_bin_bytes_suspension_includes>
+      </tdml:dfdlInfoset>
+    </tdml:infoset>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_complex_err"
+    root="pl_complex"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixComplex</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>simpleType</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_delimited_err"
+    root="pl_delimited"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixDelimited</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>lengthKind</tdml:error>
+      <tdml:error>delimited</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_endofparent_err"
+    root="pl_endofparent"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixEndOfParent</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>lengthKind</tdml:error>
+      <tdml:error>endOfParent</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_pattern_err"
+    root="pl_pattern"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixPattern</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>lengthKind</tdml:error>
+      <tdml:error>pattern</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_expression_err"
+    root="pl_expression"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixExpression</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>expression</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_ovc_err"
+    root="pl_ovc"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixOVC</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>dfdl:outputValueCalc</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_initiator_err"
+    root="pl_initiator"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixInitiator</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>dfdl:initiator</tdml:error>
+    </tdml:errors>
+
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_terminator_err"
+    root="pl_terminator"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixTerminator</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>dfdl:terminator</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_alignment_err"
+    root="pl_alignment"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixAlignment</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>dfdl:alignment</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_leadingskip_err"
+    root="pl_leadingskip"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixLeadingSkip</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>dfdl:leadingSkip</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_trailingskip_err"
+    root="pl_trailingskip"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixTrailingSkip</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>dfdl:trailingSkip</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_lengthunits_err"
+    root="pl_lengthunits"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>ex:prefixLengthUnits</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>dfdl:lengthUnits</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_nest_err"
+    root="pl_nest"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+<!--
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>Nesting level</tdml:error>
+      <tdml:error>prefixLengthNest1</tdml:error>
+      <tdml:error>prefixLengthNest2</tdml:error>
+      <tdml:error>prefixLengthNest3</tdml:error>
+
+      The above errors should be correct due to excessive nesting
+      when support for nested suspensions is implemented,
+-->
+      <tdml:error>Nested</tdml:error>
+      <tdml:error>dfdl:lengthKind="prefixed"</tdml:error>
+      <tdml:error>not supported</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+  <tdml:parserTestCase name="pl_decimal_err"
+    root="pl_decimal"
+    model="lengthKindPrefixed-sde.dfdl.xsd">
+    <tdml:document>
+      <tdml:documentPart type="text"></tdml:documentPart>
+    </tdml:document>
+    <tdml:errors>
+      <tdml:error>Schema Definition Error</tdml:error>
+      <tdml:error>dfdl:prefixLengthType</tdml:error>
+      <tdml:error>ex:prefixLengthDecimal</tdml:error>
+      <tdml:error>xs:decimal</tdml:error>
+      <tdml:error>subtype</tdml:error>
+      <tdml:error>xs:integer</tdml:error>
+    </tdml:errors>
+  </tdml:parserTestCase>
+
+</tdml:testSuite>
diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section12/lengthKind/TestLengthKindPrefixed.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section12/lengthKind/TestLengthKindPrefixed.scala
new file mode 100644
index 0000000..c9d2102
--- /dev/null
+++ b/daffodil-test/src/test/scala/org/apache/daffodil/section12/lengthKind/TestLengthKindPrefixed.scala
@@ -0,0 +1,142 @@
+/*
+ * 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.
+ */
+
+package org.apache.daffodil.section12.lengthKind
+
+import org.junit.Test
+import org.apache.daffodil.tdml.Runner
+import org.junit.AfterClass
+
+object TestLengthKindPrefixed {
+  private val testDir = "/org/apache/daffodil/section12/lengthKind/"
+
+  val runner = Runner(testDir, "PrefixedTests.tdml")
+
+  @AfterClass def shutDown {
+    runner.reset
+  }
+
+}
+
+class TestLengthKindPrefixed {
+
+  import TestLengthKindPrefixed._
+
+  @Test def test_pl_text_string_txt_bytes() = { runner.runOneTest("pl_text_string_txt_bytes") }
+  @Test def test_pl_text_string_txt_bits() = { runner.runOneTest("pl_text_string_txt_bits") }
+  @Test def test_pl_text_string_txt_chars() = { runner.runOneTest("pl_text_string_txt_chars") }
+  @Test def test_pl_text_string_txt_bytes_includes() = { runner.runOneTest("pl_text_string_txt_bytes_includes") }
+  @Test def test_pl_text_string_txt_bits_includes() = { runner.runOneTest("pl_text_string_txt_bits_includes") }
+  @Test def test_pl_text_string_txt_chars_includes() = { runner.runOneTest("pl_text_string_txt_chars_includes") }
+  @Test def test_pl_text_string_txt_chars_padding() = { runner.runOneTest("pl_text_string_txt_chars_padding") }
+  @Test def test_pl_text_string_bin_bytes() = { runner.runOneTest("pl_text_string_bin_bytes") }
+  @Test def test_pl_text_string_bin_bits() = { runner.runOneTest("pl_text_string_bin_bits") }
+  @Test def test_pl_text_string_txt_bytes_nil() = { runner.runOneTest("pl_text_string_txt_bytes_nil") }
+  @Test def test_pl_text_string_txt_bits_nil() = { runner.runOneTest("pl_text_string_txt_bits_nil") }
+  @Test def test_pl_text_string_txt_chars_nil() = { runner.runOneTest("pl_text_string_txt_chars_nil") }
+  @Test def test_pl_text_string_bin_bytes_nil() = { runner.runOneTest("pl_text_string_bin_bytes_nil") }
+  @Test def test_pl_text_string_bin_bits_nil() = { runner.runOneTest("pl_text_string_bin_bits_nil") }
+  @Test def test_pl_text_string_txt_bytes_neg_len() = { runner.runOneTest("pl_text_string_txt_bytes_neg_len") }
+  @Test def test_pl_text_string_txt_bytes_not_enough_data() = { runner.runOneTest("pl_text_string_txt_bytes_not_enough_data") }
+  @Test def test_pl_text_string_txt_bytes_not_enough_prefix_data() = { runner.runOneTest("pl_text_string_txt_bytes_not_enough_prefix_data") }
+  //DFDL-XYZ, nested prefixed lengths not supported
+  //@Test def test_pl_text_string_pl_txt_bytes() = { runner.runOneTest("pl_text_string_pl_txt_bytes") }
+  @Test def test_pl_text_int_txt_bytes() = { runner.runOneTest("pl_text_int_txt_bytes") }
+  @Test def test_pl_text_int_txt_bits() = { runner.runOneTest("pl_text_int_txt_bits") }
+  @Test def test_pl_text_int_txt_chars() = { runner.runOneTest("pl_text_int_txt_chars") }
+  @Test def test_pl_text_int_bin_bytes() = { runner.runOneTest("pl_text_int_bin_bytes") }
+  @Test def test_pl_text_int_bin_bits() = { runner.runOneTest("pl_text_int_bin_bits") }
+  @Test def test_pl_text_int_txt_bytes_includes() = { runner.runOneTest("pl_text_int_txt_bytes_includes") }
+  @Test def test_pl_text_int_txt_bits_includes() = { runner.runOneTest("pl_text_int_txt_bits_includes") }
+  @Test def test_pl_text_int_txt_chars_includes() = { runner.runOneTest("pl_text_int_txt_chars_includes") }
+  @Test def test_pl_text_int_bin_bytes_includes() = { runner.runOneTest("pl_text_int_bin_bytes_includes") }
+  @Test def test_pl_text_int_bin_bits_includes() = { runner.runOneTest("pl_text_int_bin_bits_includes") }
+  @Test def test_pl_text_dec_txt_bytes() = { runner.runOneTest("pl_text_dec_txt_bytes") }
+  @Test def test_pl_text_dec_txt_bits() = { runner.runOneTest("pl_text_dec_txt_bits") }
+  @Test def test_pl_text_dec_txt_chars() = { runner.runOneTest("pl_text_dec_txt_chars") }
+  @Test def test_pl_text_dec_bin_bytes() = { runner.runOneTest("pl_text_dec_bin_bytes") }
+  @Test def test_pl_text_dec_bin_bits() = { runner.runOneTest("pl_text_dec_bin_bits") }
+  @Test def test_pl_text_date_txt_bytes() = { runner.runOneTest("pl_text_date_txt_bytes") }
+  @Test def test_pl_text_date_txt_bits() = { runner.runOneTest("pl_text_date_txt_bits") }
+  @Test def test_pl_text_date_txt_chars() = { runner.runOneTest("pl_text_date_txt_chars") }
+  @Test def test_pl_text_date_bin_bytes() = { runner.runOneTest("pl_text_date_bin_bytes") }
+  @Test def test_pl_text_date_bin_bits() = { runner.runOneTest("pl_text_date_bin_bits") }
+  @Test def test_pl_text_bool_txt_bytes() = { runner.runOneTest("pl_text_bool_txt_bytes") }
+  @Test def test_pl_text_bool_txt_bits() = { runner.runOneTest("pl_text_bool_txt_bits") }
+  @Test def test_pl_text_bool_txt_chars() = { runner.runOneTest("pl_text_bool_txt_chars") }
+  @Test def test_pl_text_bool_bin_bytes() = { runner.runOneTest("pl_text_bool_bin_bytes") }
+  @Test def test_pl_text_bool_bin_bits() = { runner.runOneTest("pl_text_bool_bin_bits") }
+
+  @Test def test_pl_complex_bin_bytes() = { runner.runOneTest("pl_complex_bin_bytes") }
+  @Test def test_pl_complex_bin_bits() = { runner.runOneTest("pl_complex_bin_bits") }
+  @Test def test_pl_complex_bin_bytes_suspension() = { runner.runOneTest("pl_complex_bin_bytes_suspension") }
+  @Test def test_pl_complex_bin_bytes_suspension_includes() = { runner.runOneTest("pl_complex_bin_bytes_suspension_includes") }
+  @Test def test_pl_bin_int_txt_bytes() = { runner.runOneTest("pl_bin_int_txt_bytes") }
+  @Test def test_pl_bin_int_txt_bits() = { runner.runOneTest("pl_bin_int_txt_bits") }
+  @Test def test_pl_bin_int_bin_bytes() = { runner.runOneTest("pl_bin_int_bin_bytes") }
+  @Test def test_pl_bin_int_bin_bits() = { runner.runOneTest("pl_bin_int_bin_bits") }
+  @Test def test_pl_bin_int_txt_bytes_includes() = { runner.runOneTest("pl_bin_int_txt_bytes_includes") }
+  @Test def test_pl_bin_int_txt_bits_includes() = { runner.runOneTest("pl_bin_int_txt_bits_includes") }
+  @Test def test_pl_bin_int_bin_bytes_includes() = { runner.runOneTest("pl_bin_int_bin_bytes_includes") }
+  @Test def test_pl_bin_int_bin_bits_includes() = { runner.runOneTest("pl_bin_int_bin_bits_includes") }
+  @Test def test_pl_bin_int_bin_bytes_packed() = { runner.runOneTest("pl_bin_int_bin_bytes_packed") }
+  @Test def test_pl_bin_int_bin_bits_packed() = { runner.runOneTest("pl_bin_int_bin_bits_packed") }
+  @Test def test_pl_bin_int_bin_bytes_bcd() = { runner.runOneTest("pl_bin_int_bin_bytes_bcd") }
+  @Test def test_pl_bin_int_bin_bits_bcd() = { runner.runOneTest("pl_bin_int_bin_bits_bcd") }
+  @Test def test_pl_bin_int_bin_bytes_ibm4690() = { runner.runOneTest("pl_bin_int_bin_bytes_ibm4690") }
+  @Test def test_pl_bin_int_bin_bits_ibm4690() = { runner.runOneTest("pl_bin_int_bin_bits_ibm4690") }
+  @Test def test_pl_bin_dec_txt_bytes() = { runner.runOneTest("pl_bin_dec_txt_bytes") }
+  @Test def test_pl_bin_dec_txt_bits() = { runner.runOneTest("pl_bin_dec_txt_bits") }
+  @Test def test_pl_bin_dec_bin_bytes() = { runner.runOneTest("pl_bin_dec_bin_bytes") }
+  @Test def test_pl_bin_dec_bin_bits() = { runner.runOneTest("pl_bin_dec_bin_bits") }
+  @Test def test_pl_bin_dec_bin_bytes_packed() = { runner.runOneTest("pl_bin_dec_bin_bytes_packed") }
+  @Test def test_pl_bin_dec_bin_bits_packed() = { runner.runOneTest("pl_bin_dec_bin_bits_packed") }
+  @Test def test_pl_bin_dec_bin_bytes_bcd() = { runner.runOneTest("pl_bin_dec_bin_bytes_bcd") }
+  @Test def test_pl_bin_dec_bin_bits_bcd() = { runner.runOneTest("pl_bin_dec_bin_bits_bcd") }
+  @Test def test_pl_bin_dec_bin_bytes_ibm4690() = { runner.runOneTest("pl_bin_dec_bin_bytes_ibm4690") }
+  @Test def test_pl_bin_dec_bin_bits_ibm4690() = { runner.runOneTest("pl_bin_dec_bin_bits_ibm4690") }
+  @Test def test_pl_bin_hex_txt_bytes() = { runner.runOneTest("pl_bin_hex_txt_bytes") }
+  @Test def test_pl_bin_hex_txt_bits() = { runner.runOneTest("pl_bin_hex_txt_bits") }
+  @Test def test_pl_bin_hex_bin_bytes() = { runner.runOneTest("pl_bin_hex_bin_bytes") }
+  @Test def test_pl_bin_hex_bin_bits() = { runner.runOneTest("pl_bin_hex_bin_bits") }
+  @Test def test_pl_bin_bool_txt_bytes() = { runner.runOneTest("pl_bin_bool_txt_bytes") }
+  @Test def test_pl_bin_bool_txt_bits() = { runner.runOneTest("pl_bin_bool_txt_bits") }
+  @Test def test_pl_bin_bool_bin_bytes() = { runner.runOneTest("pl_bin_bool_bin_bytes") }
+  @Test def test_pl_bin_bool_bin_bits() = { runner.runOneTest("pl_bin_bool_bin_bits") }
+  @Test def test_pl_bin_date_bin_bytes_packed() = { runner.runOneTest("pl_bin_date_bin_bytes_packed") }
+  @Test def test_pl_bin_date_bin_bits_packed() = { runner.runOneTest("pl_bin_date_bin_bits_packed") }
+  @Test def test_pl_bin_date_bin_bytes_bcd() = { runner.runOneTest("pl_bin_date_bin_bytes_bcd") }
+  @Test def test_pl_bin_date_bin_bits_bcd() = { runner.runOneTest("pl_bin_date_bin_bits_bcd") }
+  @Test def test_pl_bin_date_bin_bytes_ibm4690() = { runner.runOneTest("pl_bin_date_bin_bytes_ibm4690") }
+  @Test def test_pl_bin_date_bin_bits_ibm4690() = { runner.runOneTest("pl_bin_date_bin_bits_ibm4690") }
+  @Test def test_plSlash1_data() = { runner.runOneTest("plSlash1_data") }
+
+  @Test def test_pl_complex_err() = { runner.runOneTest("pl_complex_err") }
+  @Test def test_pl_delimited_err() = { runner.runOneTest("pl_delimited_err") }
+  @Test def test_pl_endofparent_err() = { runner.runOneTest("pl_endofparent_err") }
+  @Test def test_pl_pattern_err() = { runner.runOneTest("pl_pattern_err") }
+  @Test def test_pl_expression_err() = { runner.runOneTest("pl_expression_err") }
+  @Test def test_pl_ovc_err() = { runner.runOneTest("pl_ovc_err") }
+  @Test def test_pl_initiator_err() = { runner.runOneTest("pl_initiator_err") }
+  @Test def test_pl_terminator_err() = { runner.runOneTest("pl_terminator_err") }
+  @Test def test_pl_alignment_err() = { runner.runOneTest("pl_alignment_err") }
+  @Test def test_pl_leadingskip_err() = { runner.runOneTest("pl_leadingskip_err") }
+  @Test def test_pl_trailingskip_err() = { runner.runOneTest("pl_trailingskip_err") }
+  @Test def test_pl_lengthunits_err() = { runner.runOneTest("pl_lengthunits_err") }
+  @Test def test_pl_nest_err() = { runner.runOneTest("pl_nest_err") }
+  @Test def test_pl_decimal_err() = { runner.runOneTest("pl_decimal_err") }
+}